/*
Copyright 2011, CSE Shareware Foundation
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, 
are permitted provided that the following conditions are met:

 * Redistributions of source code must retain the above copyright notice, 
   this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, 
   this list of conditions and the following disclaimer in the documentation 
   and/or other materials provided with the distribution.
 * Neither the name of CSE Shareware Foundation nor the names of its contributors 
   may be used to endorse or promote products derived from this software without 
   specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "CseApi_.h"
#include "CseApi/CseSuper.h"

#ifdef __linux__
  #include <pthread.h>

  static unsigned long GetCurrentThreadId()
  {
    pthread_t t = pthread_self();
    return *(unsigned long*)t;
  }

#else
  #include <windows.h>
#endif

extern TCseObj Cse_InnerEval(const TCseObj& expr);

CseObj SuperComponents = NULL;    // all components
CseObj SuperEntities   = NULL;    // all cached entities
CseObj SuperEvents     = NULL;    // all events {EventName:hooks} // hooks {EID:[callback...]}
CseObj SuperCurrRoot   = NULL;    // root entity for S.e(), exist temporary
CseObj SuperNewCallback = NULL;   // callback function list for new-entity-event

CseObj CseSuper_unknown  = NULL;  // type unknown, value unknown

CseObj SuperEntityType   = NULL;  // type of _TEntity
CseObj SuperArrayType    = NULL;  // type of _TArray
CseObj SuperSelectorType = NULL;  // type of _TSelector

CseObj SuperWeakDummy    = NULL;  // weak(dummy)
CseObj SuperConvertFunc  = NULL;
CseObj SuperClosureArgs  = NULL;  // "(*args)"

CseObj constInit     = NULL;
CseObj constRemove   = NULL;
CseObj constOpCall   = NULL;
CseObj constEllipsis = NULL;
CseObj constSObject  = NULL;
CseObj constUndefined= NULL;
CseObj constI = NULL;
CseObj constW = NULL;
CseObj constF = NULL;
CseObj constS = NULL;
CseObj constT = NULL;
CseObj constB = NULL;
CseObj constD = NULL;
CseObj constV = NULL;

_TEntity *CseSuper_UnknownObj = NULL;

void (*CseSuper_AfterExit)(const TCseObj& b) = NULL;

TCseObj SARG()
{
    return CseEmptyBuff;
}

TCseObj SARG(const TCseObj& arg0)
{
    TObjArray bArg(1);
    bArg.addr()[0] = Cse_IncRefEx(arg0);
    return TCseObj(CUT_FROM,bArg);
}

TCseObj SARG(const TCseObj& arg0,const TCseObj& arg1)
{
    TObjArray bArg(2);
    CseObj *bRet = bArg.addr();

    bRet[0] = Cse_IncRefEx(arg0);
    bRet[1] = Cse_IncRefEx(arg1);

    return TCseObj(CUT_FROM,bArg);
}

TCseObj SARG(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2)
{
    TObjArray bArg(3);
    CseObj *bRet = bArg.addr();

    bRet[0] = Cse_IncRefEx(arg0);
    bRet[1] = Cse_IncRefEx(arg1);
    bRet[2] = Cse_IncRefEx(arg2);

    return TCseObj(CUT_FROM,bArg);
}

TCseObj SARG(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3)
{
    TObjArray bArg(4);
    CseObj *bRet = bArg.addr();

    bRet[0] = Cse_IncRefEx(arg0);
    bRet[1] = Cse_IncRefEx(arg1);
    bRet[2] = Cse_IncRefEx(arg2);
    bRet[3] = Cse_IncRefEx(arg3);

    return TCseObj(CUT_FROM,bArg);
}

TCseObj SARG(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4)
{
    TObjArray bArg(5);
    CseObj *bRet = bArg.addr();

    bRet[0] = Cse_IncRefEx(arg0);
    bRet[1] = Cse_IncRefEx(arg1);
    bRet[2] = Cse_IncRefEx(arg2);
    bRet[3] = Cse_IncRefEx(arg3);
    bRet[4] = Cse_IncRefEx(arg4);

    return TCseObj(CUT_FROM,bArg);
}

TCseObj SARG(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5)
{
    TObjArray bArg(6);
    CseObj *bRet = bArg.addr();

    bRet[0] = Cse_IncRefEx(arg0);
    bRet[1] = Cse_IncRefEx(arg1);
    bRet[2] = Cse_IncRefEx(arg2);
    bRet[3] = Cse_IncRefEx(arg3);
    bRet[4] = Cse_IncRefEx(arg4);
    bRet[5] = Cse_IncRefEx(arg5);

    return TCseObj(CUT_FROM,bArg);
}

TCseObj SARG(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6)
{
    TObjArray bArg(7);
    CseObj *bRet = bArg.addr();

    bRet[0] = Cse_IncRefEx(arg0);
    bRet[1] = Cse_IncRefEx(arg1);
    bRet[2] = Cse_IncRefEx(arg2);
    bRet[3] = Cse_IncRefEx(arg3);
    bRet[4] = Cse_IncRefEx(arg4);
    bRet[5] = Cse_IncRefEx(arg5);
    bRet[6] = Cse_IncRefEx(arg6);

    return TCseObj(CUT_FROM,bArg);
}

TCseObj SARG(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7)
{
    TObjArray bArg(8);
    CseObj *bRet = bArg.addr();

    bRet[0] = Cse_IncRefEx(arg0);
    bRet[1] = Cse_IncRefEx(arg1);
    bRet[2] = Cse_IncRefEx(arg2);
    bRet[3] = Cse_IncRefEx(arg3);
    bRet[4] = Cse_IncRefEx(arg4);
    bRet[5] = Cse_IncRefEx(arg5);
    bRet[6] = Cse_IncRefEx(arg6);
    bRet[7] = Cse_IncRefEx(arg7);

    return TCseObj(CUT_FROM,bArg);
}

TCseObj SARG(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8)
{
    TObjArray bArg(9);
    CseObj *bRet = bArg.addr();

    bRet[0] = Cse_IncRefEx(arg0);
    bRet[1] = Cse_IncRefEx(arg1);
    bRet[2] = Cse_IncRefEx(arg2);
    bRet[3] = Cse_IncRefEx(arg3);
    bRet[4] = Cse_IncRefEx(arg4);
    bRet[5] = Cse_IncRefEx(arg5);
    bRet[6] = Cse_IncRefEx(arg6);
    bRet[7] = Cse_IncRefEx(arg7);
    bRet[8] = Cse_IncRefEx(arg8);

    return TCseObj(CUT_FROM,bArg);
}

TCseObj SARG(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8,const TCseObj& arg9)
{
    TObjArray bArg(10);
    CseObj *bRet = bArg.addr();

    bRet[0] = Cse_IncRefEx(arg0);
    bRet[1] = Cse_IncRefEx(arg1);
    bRet[2] = Cse_IncRefEx(arg2);
    bRet[3] = Cse_IncRefEx(arg3);
    bRet[4] = Cse_IncRefEx(arg4);
    bRet[5] = Cse_IncRefEx(arg5);
    bRet[6] = Cse_IncRefEx(arg6);
    bRet[7] = Cse_IncRefEx(arg7);
    bRet[8] = Cse_IncRefEx(arg8);
    bRet[9] = Cse_IncRefEx(arg9);

    return TCseObj(CUT_FROM,bArg);
}

TCseObj SARG(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8,const TCseObj& arg9,const TCseObj& arg10)
{
    TObjArray bArg(11);
    CseObj *bRet = bArg.addr();

    bRet[0] = Cse_IncRefEx(arg0);
    bRet[1] = Cse_IncRefEx(arg1);
    bRet[2] = Cse_IncRefEx(arg2);
    bRet[3] = Cse_IncRefEx(arg3);
    bRet[4] = Cse_IncRefEx(arg4);
    bRet[5] = Cse_IncRefEx(arg5);
    bRet[6] = Cse_IncRefEx(arg6);
    bRet[7] = Cse_IncRefEx(arg7);
    bRet[8] = Cse_IncRefEx(arg8);
    bRet[9] = Cse_IncRefEx(arg9);
    bRet[10] = Cse_IncRefEx(arg10);

    return TCseObj(CUT_FROM,bArg);
}

TCseObj SARG(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8,const TCseObj& arg9,const TCseObj& arg10,const TCseObj& arg11)
{
    TObjArray bArg(12);
    CseObj *bRet = bArg.addr();

    bRet[0] = Cse_IncRefEx(arg0);
    bRet[1] = Cse_IncRefEx(arg1);
    bRet[2] = Cse_IncRefEx(arg2);
    bRet[3] = Cse_IncRefEx(arg3);
    bRet[4] = Cse_IncRefEx(arg4);
    bRet[5] = Cse_IncRefEx(arg5);
    bRet[6] = Cse_IncRefEx(arg6);
    bRet[7] = Cse_IncRefEx(arg7);
    bRet[8] = Cse_IncRefEx(arg8);
    bRet[9] = Cse_IncRefEx(arg9);
    bRet[10] = Cse_IncRefEx(arg10);
    bRet[11] = Cse_IncRefEx(arg11);

    return TCseObj(CUT_FROM,bArg);
}

TCseObj SARG(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8,const TCseObj& arg9,const TCseObj& arg10,const TCseObj& arg11,const TCseObj& arg12)
{
    TObjArray bArg(13);
    CseObj *bRet = bArg.addr();

    bRet[0] = Cse_IncRefEx(arg0);
    bRet[1] = Cse_IncRefEx(arg1);
    bRet[2] = Cse_IncRefEx(arg2);
    bRet[3] = Cse_IncRefEx(arg3);
    bRet[4] = Cse_IncRefEx(arg4);
    bRet[5] = Cse_IncRefEx(arg5);
    bRet[6] = Cse_IncRefEx(arg6);
    bRet[7] = Cse_IncRefEx(arg7);
    bRet[8] = Cse_IncRefEx(arg8);
    bRet[9] = Cse_IncRefEx(arg9);
    bRet[10] = Cse_IncRefEx(arg10);
    bRet[11] = Cse_IncRefEx(arg11);
    bRet[12] = Cse_IncRefEx(arg12);

    return TCseObj(CUT_FROM,bArg);
}

TCseObj SARG(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8,const TCseObj& arg9,const TCseObj& arg10,const TCseObj& arg11,const TCseObj& arg12,const TCseObj& arg13)
{
    TObjArray bArg(14);
    CseObj *bRet = bArg.addr();

    bRet[0] = Cse_IncRefEx(arg0);
    bRet[1] = Cse_IncRefEx(arg1);
    bRet[2] = Cse_IncRefEx(arg2);
    bRet[3] = Cse_IncRefEx(arg3);
    bRet[4] = Cse_IncRefEx(arg4);
    bRet[5] = Cse_IncRefEx(arg5);
    bRet[6] = Cse_IncRefEx(arg6);
    bRet[7] = Cse_IncRefEx(arg7);
    bRet[8] = Cse_IncRefEx(arg8);
    bRet[9] = Cse_IncRefEx(arg9);
    bRet[10] = Cse_IncRefEx(arg10);
    bRet[11] = Cse_IncRefEx(arg11);
    bRet[12] = Cse_IncRefEx(arg12);
    bRet[13] = Cse_IncRefEx(arg13);

    return TCseObj(CUT_FROM,bArg);
}

TCseObj SARG(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8,const TCseObj& arg9,const TCseObj& arg10,const TCseObj& arg11,const TCseObj& arg12,const TCseObj& arg13,const TCseObj& arg14)
{
    TObjArray bArg(15);
    CseObj *bRet = bArg.addr();

    bRet[0] = Cse_IncRefEx(arg0);
    bRet[1] = Cse_IncRefEx(arg1);
    bRet[2] = Cse_IncRefEx(arg2);
    bRet[3] = Cse_IncRefEx(arg3);
    bRet[4] = Cse_IncRefEx(arg4);
    bRet[5] = Cse_IncRefEx(arg5);
    bRet[6] = Cse_IncRefEx(arg6);
    bRet[7] = Cse_IncRefEx(arg7);
    bRet[8] = Cse_IncRefEx(arg8);
    bRet[9] = Cse_IncRefEx(arg9);
    bRet[10] = Cse_IncRefEx(arg10);
    bRet[11] = Cse_IncRefEx(arg11);
    bRet[12] = Cse_IncRefEx(arg12);
    bRet[13] = Cse_IncRefEx(arg13);
    bRet[14] = Cse_IncRefEx(arg14);

    return TCseObj(CUT_FROM,bArg);
}

TCseObj SARG(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8,const TCseObj& arg9,const TCseObj& arg10,const TCseObj& arg11,const TCseObj& arg12,const TCseObj& arg13,const TCseObj& arg14,const TCseObj& arg15)
{
    TObjArray bArg(16);
    CseObj *bRet = bArg.addr();

    bRet[0] = Cse_IncRefEx(arg0);
    bRet[1] = Cse_IncRefEx(arg1);
    bRet[2] = Cse_IncRefEx(arg2);
    bRet[3] = Cse_IncRefEx(arg3);
    bRet[4] = Cse_IncRefEx(arg4);
    bRet[5] = Cse_IncRefEx(arg5);
    bRet[6] = Cse_IncRefEx(arg6);
    bRet[7] = Cse_IncRefEx(arg7);
    bRet[8] = Cse_IncRefEx(arg8);
    bRet[9] = Cse_IncRefEx(arg9);
    bRet[10] = Cse_IncRefEx(arg10);
    bRet[11] = Cse_IncRefEx(arg11);
    bRet[12] = Cse_IncRefEx(arg12);
    bRet[13] = Cse_IncRefEx(arg13);
    bRet[14] = Cse_IncRefEx(arg14);
    bRet[15] = Cse_IncRefEx(arg15);

    return TCseObj(CUT_FROM,bArg);
}

_TEntity::_TEntity(): TCseObj(CseEmptyBuff)
{
    append(CseSuper_unknown);
    append(dummy);
}

_TEntity::_TEntity(CseObj obj): TCseObj(obj) 
{
    if (CseSuper_unknown == obj)
        *(TCseObj*)this = *CseSuper_UnknownObj;
    CHECK_MSG( CSE_TYPE(m_data) == dtBuff && Cse_len(m_data) == 2 && 
               Cse_OptionOn(m_data->bValue[0],16), _T("entity format error"));
}

_TEntity& _TEntity::operator=(const _TEntity& obj)
{
    ASSERT_TRUE(CSE_TYPE(obj.m_data) == dtBuff && Cse_len(obj.m_data) == 2 && Cse_OptionOn(obj.m_data->bValue[0],16));

    *(TCseObj*)this = obj.m_data;
    return *this;
}

_TEntity& _TEntity::operator=(const SClosure& obj)
{
    _TEntity en;
    en->Id_ = SuperEntityType;
    en->value = obj;

    *(TCseObj*)this = en.m_data;
    return *this;
}

TBool _TEntity::operator==(const _TEntity& obj) const
{
    return m_data == (CseObj)obj;
}

TBool _TEntity::operator==(CseObj obj) const
{
    if (CseSuper_unknown == obj)
        return *this == *CseSuper_UnknownObj;
    else return m_data == obj;
}

TBool _TEntity::operator!=(const _TEntity& obj) const
{
    return m_data != (CseObj)obj;
}

TBool _TEntity::operator!=(CseObj obj) const
{
    if (CseSuper_unknown == obj)
        return *(CseObj*)this != *(CseObj*)CseSuper_UnknownObj;
    else return m_data != obj;
}

TBool operator==(CseObj obj1, const _TEntity& obj2)
{
    return obj2 == obj1;
}

TBool operator!=(CseObj obj1, const _TEntity& obj2)
{
    return obj2 != obj1;
}

_TEntity _TEntity::operator[](const TXchar* attr) const
{
    TCseObj name = TCseObj::format(CSE_ID,attr);

    if (dummy != m_data->bValue[1])
    {   // it is entity, not a class
        _TEntity ret = CseSuper_EntityAttr(self,name,false);
        if (CseSuper_unknown != (CseObj)ret->Id_)
            return ret;
    }

    return CseSuper_EntityAttr(self,name,true,2);  // find from prototype
}

_TEntity _TEntity::operator[](const TCseObj& attr) const
{
    TCseObj name = attr.toId();
    if (dummy != m_data->bValue[1])
    {   // it is entity, not a class
        _TEntity ret = CseSuper_EntityAttr(self,name,false);
        if (CseSuper_unknown != (CseObj)ret->Id_)
            return ret;
    }

    return CseSuper_EntityAttr(self,name,true,2); // find from prototype
}

TBool _TEntity::isThisCall(TInt& RetId, TInt& DefNum, TInt& VaNum, TBool& isType, TInt iInput) const
{
    CseObj bType = self->Id_;
    ASSERT_TRUE(CSE_TYPE(bType) == dtBuff && Cse_OptionOn(bType,16));

    int iLen = CSE_ARRAY_LEN(bType->bValue);
    ASSERT_TRUE(iLen >= 1);

    if (CseSuper_unknown == bType)
    {
        isType = true;
        RetId = -1;
        DefNum = 0;
        VaNum = 0;
        return false;     // isThis = false;
    }

    isType = (dummy == self->value);

    TInt iFlag = bType->bValue[0]->iValue;
    if (iFlag == 2 && iLen >= 3)  // function
    {   // [stSuperFunc|size,retType,[dummy_weak(bOwner),sArgs], arg0 ...]
        CseObj vId = bType->bValue[1];
        if (dummy == vId)
            RetId = 0;
        else if (vId == constV)
            RetId = 1;
        else if (vId == constI)
            RetId = 2;
        else if (vId == constS)
            RetId = 3;
        else if (vId == constT)
            RetId = 4;
        else if (vId == constB)
            RetId = 5;
        else if (vId == constD)
            RetId = 6;
        else if (vId == constW)
            RetId = 7;
        else if (vId == constF)
            RetId = 8;
        else RetId = 1;

        TInt iTotalArg = iLen - 3;
        TInt iDefaultArg = 0;

        TCseObj bInfo = bType->bValue[2];
        int InfoLen = bInfo.len();
        int iVaArg = (iLen >= 4 && bType->bValue[iLen - 1] == constEllipsis)? 1 : 0;
        ASSERT_TRUE(InfoLen >= 1);

        if (InfoLen >= 3 && (iDefaultArg = bInfo.sub(2).len()) > 0)
        {
            ASSERT_TRUE(iDefaultArg <= iTotalArg - iVaArg);
            int iFixNum = iTotalArg - iVaArg - iDefaultArg;
            if (iInput < iFixNum)
            {
                TCharArray sErr = TCharArray::format(_T("function require %d argument(s) at least, but %d passed"),iFixNum,iInput);
                throw LOG_CSE_ERR(CSE_ARGS_ERR,sErr);
            }
            if (iVaArg == 0 && iInput > iTotalArg)
            {
                TCharArray sErr = TCharArray::format(_T("function require %d argument(s) at most, but %d passed"),iTotalArg,iInput);
                throw LOG_CSE_ERR(CSE_ARGS_ERR,sErr);
            }

            DefNum = iTotalArg - iVaArg - iInput;
            if (DefNum < 0)
            {   // too many input
                ASSERT_TRUE(iVaArg != 0); // if iVaArg == 0, alread raise error at previous step
                VaNum = 1 - DefNum;       // 2 ~ N, means uses 1 ~ N-1 arguments as bArgs
                DefNum = 0;
            }
            else if (DefNum == 0)
            {
                if (iVaArg != 0)
                    VaNum = 1;            // means uses CseEmptyBuff as bArgs
                else VaNum = 0;           // means not using bArgs
            }
            else // DefNum > 0
            {
                VaNum = iVaArg;
            }
        }
        else
        {
            int iFixNum = iTotalArg - iVaArg;
            if (iInput < iFixNum || (iVaArg == 0 && iInput > iFixNum))
            {
                TCharArray sErr = TCharArray::format(_T("function require %d argument(s), but %d passed"),iFixNum,iInput);
                throw LOG_CSE_ERR(CSE_ARGS_ERR,sErr);
            }

            DefNum = 0;
            VaNum = (iVaArg == 0)? 0 : iInput - iFixNum + 1;  // 0 : 1 ~ N
        }

        TBool isThis = dummy != bInfo.sub(0);
        ASSERT_TRUE(! (isType && isThis));  // class method must not none-init
        return isThis;
    }
    else
    {
        if (iFlag == 1 || iFlag == 3)  // UDT or Array
        {
            if (isType)       // normal none-init UDT
                RetId = -1;
            else RetId = -2;
            DefNum = 0;
            VaNum = 0;
            return false;     // isThis = false;
        }
    }

    throw LOG_CSE_ERR(CSE_VALUE_ERR,_T("entity is not a function"));
}

TCseException NoInitFuncErr()
{
    return LOG_CSE_ERR(CSE_TYPE_ERR,_T("call NULL address"));
}

TCseObj CopyUdtInitValue(const TCseObj& arg)
{
    int tp = Cse_type(arg);
    if (tp == dtInt)
        return arg.iObj();
    else if (tp == dtStr)
        return arg.sArray();
    else if (tp == dtTier)
        return arg.tArray();
    else if (tp == dtBuff)
        return arg.bArray();
    else if (tp == dtDict)
        return arg.dArray();
    else if (tp == dtWint)
        return arg.wObj();
    else if (tp == dtFloat)
        return arg.fObj();
    else return arg;
}

TCseObj CreateUdtComponent(const _TEntity& me, const TCseObj& bArgs)
{
    TCseObj bType = me->Id_;
    ASSERT_TRUE(Cse_OptionOn(bType,16) && Cse_type(bType) == dtBuff && bType.len() > 0);
    CseObj vFlag = bType.sub(0);
    if (CseSuper_unknown == vFlag)
        return _TEntity();  // ret->Id_ is CseSuper_unknown

    if ( vFlag->iValue != 3 && (vFlag->iValue != 1 || vFlag->iFlag < 0) ) 
        throw LOG_CSE_ERR(CSE_SYSTEM_ERR,_T("entity type format error"));

    TCseObj bRet(CseEmptyBuff);
    if (vFlag->iFlag > 0)
    {
        bRet.bArray().resize(vFlag->iFlag);

        if (vFlag->iValue == 1)
        {
            TCseObj bInitValue,bAttr;
            int iInitLen;
            if (bType.len() >= 7 && (iInitLen = (bInitValue = bType.sub(6)).len()) == (bAttr = bType.sub(1)).len())
            {
                TCseObj bAttrInfo = bType.sub(2);
                TCseObj *pObj = (TCseObj *)bRet->bValue;
                for (int i = 0; i < iInitLen; i++)
                {
                    int iOff = i << 1;
                    bRet.sub(bAttrInfo.sub(iOff)->iValue) = CopyUdtInitValue(bInitValue.sub(i));
                }
            }
        }
    }

    _TEntity entity;
    entity->Id_ = bType;
    entity->value = bRet;

    // only find init() from prototype
    _TEntity vFunc = CseSuper_EntityAttr(entity,constInit,false,2);
    CseObj bSubType = vFunc->Id_;
    if (CseSuper_unknown != bSubType)   // has 'init' function
    {
        ASSERT_TRUE(Cse_OptionOn(bSubType,16) && CSE_TYPE(bSubType) == dtBuff);
        if (CSE_ARRAY_LEN(bSubType->bValue) >= 4 && bSubType->bValue[0]->iValue == 2)
        {   // call entity.init(...)
            if (SuperEntityType == bSubType->bValue[3]->vValue)
                vFunc.apply(entity,bArgs);
            else vFunc.apply(entity->value,bArgs);
        }
        else throw LOG_CSE_ERR(CSE_SYNTAX_ERR,_T("init function format error"));
    }

    return entity;
}

TCseObj CopyDefaultArg(const TCseObj& arg)
{
    if (dummy == arg)
        return dummy;

    int tp = Cse_type(arg);
    if (tp == dtInt)
        return arg.iObj();
    else if (tp == dtStr)
        return arg.sArray();
    else if (tp == dtWint)
        return arg.wObj();
    else if (tp == dtFloat)
        return arg.fObj();
    else if (tp == dtTier)
        return arg.tArray();
    else if (tp == dtBuff)
    {
        if (arg.len() > 0 && (CseSuper_unknown == arg.sub(0) || CseSuper_unknown == arg))
            return *CseSuper_UnknownObj;
        else return arg.bArray();
    }
    else if (tp == dtDict)
        return arg.dArray();
    // else, error

    TCharArray sErr = _T("illegal type of function default argument: ");
    sErr += Cse_GetTypeName(tp);
    throw LOG_CSE_ERR(CSE_ARGS_ERR,sErr);
}

TCseObj CallUdtEntity(const _TEntity& me, const TCseObj& bArgs)
{
    TCseObj bType = me->Id_;
    ASSERT_TRUE(Cse_OptionOn(bType,16) && Cse_type(bType) == dtBuff && bType.len() > 0);
    CseObj vFlag = bType.sub(0);
    if ( vFlag->iValue != 3 && (vFlag->iValue != 1 || vFlag->iFlag < 0) ) 
        throw LOG_CSE_ERR(CSE_SYSTEM_ERR,_T("entity type format error"));

    TCseObj value = me->value;
    if (value.optionOn(20))
    {   // closure call
        ASSERT_TRUE(value.type() == dtBuff && value.len() == 2);

        SClosure& clsr = (SClosure&) value;
        _TEntity fn = (CseObj)clsr.sub(0);
        CseObj FnType = fn.sub(0);
        ASSERT_TRUE(Cse_OptionOn(FnType,16) && FnType->bValue[0]->iValue == 2);

        int iLen = CSE_ARRAY_LEN(FnType->bValue);
        TInt iTotalArg = iLen - 3;
        if (iTotalArg > 0)
        {
            TCseObj bInfo = FnType->bValue[2];
            if (bInfo.len() >= 3)
            {
                TCseObj bDefArgs = bInfo.sub(2);
                int iDefaultArg = bDefArgs.len();

                if (iDefaultArg > 0)
                {
                    int iVaArg = (iLen >= 4 && FnType->bValue[iLen - 1] == constEllipsis)? 1 : 0;
                    int DefNum = (iTotalArg - iVaArg) - bArgs.len();  // need DefNum's default-argument
                    if (DefNum  > 0)
                    {
                        if (DefNum > iDefaultArg)
                            throw LOG_CSE_ERR(CSE_ARGS_ERR,_T("insufficient argument passed to SClosure"));

                        TCseObj NewArgs(CseEmptyBuff);
                        NewArgs.join(bArgs);

                        for (TInt i = iDefaultArg - DefNum; i < iDefaultArg; i++)
                        {
                            TCseObj OneArg = bDefArgs.sub(i);
                            if (Cse_type(OneArg) == dtWeak)  // variant
                                NewArgs.append(OneArg->vValue);
                            else NewArgs.append(CopyDefaultArg(OneArg));
                        }

                        return clsr(NewArgs);
                    }
                }
            }
        }

        return clsr(bArgs);
    }

    // only find operator() from prototype
    _TEntity vFunc = CseSuper_EntityAttr(me,constOpCall,true,2);
    return vFunc.call(bArgs);
}

TCseObj EvalAndConvert(const TCseObj& item, CseObj bType)
{
    if (SuperConvertFunc == NULL || SuperConvertFunc->iValue == 0)
        throw LOG_CSE_ERR(CSE_ARGS_ERR,_T("illegal super-function default argument"));

    TCseObj (*callback)(TBool&,const TCseObj&,CseObj) = (TCseObj (*)(TBool&,const TCseObj&,CseObj))SuperConvertFunc->iValue;
    TCseObj value = Cse_InnerEval(item);

    TBool isOk = true;
    TCseObj ret = callback(isOk,value,bType);
    if (! isOk)
        throw LOG_CSE_ERR(CSE_ARGS_ERR,_T("can not convert default argument"));
    return ret;
}

TCseObj CallVaArgCdeclFunc(const _TEntity& me, TInt DefNum, TInt VaNum, const TCseObj& bArgs)
{
    TCseObj VaListArg;
    TBool hasVaArg = false;
    if (VaNum > 0)
    {
        ASSERT_TRUE(bArgs.len() >= VaNum - 1);
        ASSERT_TRUE(VaNum != 2 || !Cse_OptionOn(bArgs.sub(-1),17));

        TObjArray bEllipsis;
        while (VaNum > 1)
        {
            bEllipsis.insert(0,bArgs.pop());
            VaNum--;
        }

        hasVaArg = true;
        VaListArg = TCseObj(CUT_FROM,bEllipsis);
        Cse_SetOption(VaListArg,17);  // VaListArg is ready
    }

    if (DefNum > 0)
    {
        TCseObj bFuncType = me->Id_;
        TCseObj bDefArgs  = bFuncType.sub(2).sub(2);
        TBool needConvert = (Cse_type(me->value) == dtStrong);
        int iDefBeg = bFuncType.len() - bDefArgs.len();
        if (hasVaArg) iDefBeg--;

        TInt iLen = bDefArgs.len();
        for (TInt i = iLen - DefNum; i < iLen; i++)
        {
            TCseObj OneArg = bDefArgs.sub(i);
            if (needConvert)
            {
                TCseObj bOneType = bFuncType.sub(iDefBeg+i);
                ASSERT_TRUE(Cse_type(bOneType) == dtWeak || Cse_type(bOneType) == dtStrong);
                bArgs.append(EvalAndConvert(OneArg,bOneType->vValue));
            }
            else if (Cse_type(OneArg) == dtWeak)  // variant
                bArgs.append(OneArg->vValue);
            else bArgs.append(CopyDefaultArg(OneArg));
        }
    }

    if (hasVaArg)
        bArgs.append(VaListArg);

    return me.call(bArgs);
}

TCseObj CallVaArgThiscallFunc( const _TEntity& me, const TCseObj& This, TInt DefNum,
                               TInt VaNum, const TCseObj& bArgs )
{
    TCseObj VaListArg;
    TBool hasVaArg = false;
    if (VaNum > 0)
    {
        ASSERT_TRUE(bArgs.len() >= VaNum - 1);

        TObjArray bEllipsis;
        while (VaNum > 1)
        {
            bEllipsis.insert(0,bArgs.pop());
            VaNum--;
        }

        hasVaArg = true;
        VaListArg = TCseObj(CUT_FROM,bEllipsis);
        Cse_SetOption(VaListArg,17);  // VaListArg is ready
    }

    if (DefNum > 0)
    {
        TCseObj bFuncType = me->Id_;
        TCseObj bDefArgs  = bFuncType.sub(2).sub(2);
        TBool needConvert = (Cse_type(me->value) == dtStrong);
        int iDefBeg = bFuncType.len() - bDefArgs.len();
        if (hasVaArg) iDefBeg--;

        TInt iLen = bDefArgs.len();
        for (TInt i = iLen - DefNum; i < iLen; i++)
        {
            TCseObj OneArg = bDefArgs.sub(i);
            if (needConvert)
            {
                TCseObj bOneType = bFuncType.sub(iDefBeg+i);
                ASSERT_TRUE(Cse_type(bOneType) == dtWeak || Cse_type(bOneType) == dtStrong);
                bArgs.append(EvalAndConvert(OneArg,bOneType->vValue));
            }
            else if (Cse_type(OneArg) == dtWeak)
                bArgs.append(OneArg->vValue);
            else bArgs.append(CopyDefaultArg(OneArg));
        }
    }

    if (hasVaArg)
        bArgs.append(VaListArg);

    return me.apply(This,bArgs);
}

#define NEED_VA(VaNum,arg)    (VaNum > 0 && !(VaNum == 2 && Cse_OptionOn(arg,17)))

TCseObj _TEntity::operator()() const
{
    TInt RetId = 0;     // void v i s t b d w f
    TInt DefArgNum = 0;
    TInt VaArgNum = 0;
    TBool isType;
    if (! isThisCall(RetId,DefArgNum,VaArgNum,isType,0))
    {
        if (RetId == -2)
            return CallUdtEntity(self,CseEmptyBuff);
        else if (isType)
        {
            if (RetId >= 0)  // none-init function
                throw NoInitFuncErr();
            else
            {
                ASSERT_TRUE(RetId == -1);
                return CreateUdtComponent(self,CseEmptyBuff);
            }
        }

        if (DefArgNum > 0 || VaArgNum > 0)
            return CallVaArgCdeclFunc(self,DefArgNum,VaArgNum,CseEmptyBuff);
        // else, DefArgNum == 0 && VaArgNum == 0

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {   // void
            ((void (*)()) func)();
            return dummy;
        }
        else if (RetId == 1)    // TCseObj
            return ((TCseObj (*)()) func)();
        else if (RetId == 2)    // TIntObj
            return ((TIntObj (*)()) func)();
        else if (RetId == 3)    // TCharArray
            return ((TCharArray (*)()) func)();
        else if (RetId == 4)    // TIntArray
            return ((TIntArray (*)()) func)();
        else if (RetId == 5)    // TObjArray
            return ((TObjArray (*)()) func)();
        else if (RetId == 6)    // TEntryArray
            return ((TEntryArray (*)()) func)();
        else if (RetId == 7)    // TWintObj
            return ((TWintObj (*)()) func)();
        else
        {   // ASSERT_TRUE(RetId == 8);  // TFloatObj
            return ((TFloatObj (*)()) func)();
        }
    }
    throw LOG_CSE_ERR(CSE_VALUE_ERR,_T("method can not called as function"));
}

TCseObj _TEntity::operator()(const TCseObj& arg0) const
{
    TInt RetId = 0;     // void v i s t b d w f
    TInt DefArgNum = 0;
    TInt VaArgNum = 0;
    TBool isType;
    if (! isThisCall(RetId,DefArgNum,VaArgNum,isType,1))
    {
        if (RetId == -2)
            return CallUdtEntity(self,SARG(arg0));
        else if (isType)
        {
            if (RetId >= 0)  // none-init function
            {
                CseObj vFuncAddr = arg0;
                int ArgTp = CSE_TYPE(vFuncAddr);
                if ( (ArgTp == dtInt && vFuncAddr->iValue == 0xCCCCCCCC) || (ArgTp == dtStrong && CSE_TYPE(vFuncAddr->vValue) == dtBuff) )
                {   // init function address and call:  AFuncType(iAddr)(...)
                    _TEntity vFunc;
                    vFunc->Id_ = self->Id_;
                    vFunc->value = arg0;
                    return vFunc();
                }
                else throw NoInitFuncErr();
            }
            else
            {
                ASSERT_TRUE(RetId == -1);
                return CreateUdtComponent(self,SARG(arg0));
            }
        }

        if (DefArgNum > 0 || NEED_VA(VaArgNum,arg0))
            return CallVaArgCdeclFunc(self,DefArgNum,VaArgNum,SARG(arg0));

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            ((void (*)(const TCseObj&)) func)(arg0);
            return dummy;
        }
        else if (RetId == 1)
            return ((TCseObj (*)(const TCseObj&)) func)(arg0); 
        else if (RetId == 2)
            return ((TIntObj (*)(const TCseObj&)) func)(arg0); 
        else if (RetId == 3)
            return ((TCharArray (*)(const TCseObj&)) func)(arg0); 
        else if (RetId == 4)
            return ((TIntArray (*)(const TCseObj&)) func)(arg0); 
        else if (RetId == 5)
            return ((TObjArray (*)(const TCseObj&)) func)(arg0); 
        else if (RetId == 6)
            return ((TEntryArray (*)(const TCseObj&)) func)(arg0); 
        else if (RetId == 7)
            return ((TWintObj (*)(const TCseObj&)) func)(arg0); 
        else // if (RetId == 8)
            return ((TFloatObj (*)(const TCseObj&)) func)(arg0); 
    }
    else
    {
        if (DefArgNum > 0 || VaArgNum > 0)
            return CallVaArgThiscallFunc(self,arg0,DefArgNum,VaArgNum,CseEmptyBuff);

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            union {
                void (TCseObj::* method)();
                void *addr;
            } AMethod;
            AMethod.addr = func;
            (((TCseObj*)&arg0)->* AMethod.method)();
            return dummy;
        }
        else if (RetId == 1)
        {
            union {
                TCseObj (TCseObj::* method)();
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)();
        }
        else if (RetId == 2)
        {
            union {
                TIntObj (TCseObj::* method)();
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)();
        }
        else if (RetId == 3)
        {
            union {
                TCharArray (TCseObj::* method)();
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)();
        }
        else if (RetId == 4)
        {
            union {
                TIntArray (TCseObj::* method)();
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)();
        }
        else if (RetId == 5)
        {
            union {
                TObjArray (TCseObj::* method)();
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)();
        }
        else if (RetId == 6)
        {
            union {
                TEntryArray (TCseObj::* method)();
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)();
        }
        else if (RetId == 7)
        {
            union {
                TWintObj (TCseObj::* method)();
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)();
        }
        else // if (RetId == 8)
        {
            union {
                TFloatObj (TCseObj::* method)();
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)();
        }
    }
}

TCseObj _TEntity::operator()(const TCseObj& arg0,const TCseObj& arg1) const
{
    TInt RetId = 0;     // void v i s t b d w f
    TInt DefArgNum = 0;
    TInt VaArgNum = 0;
    TBool isType;
    if (! isThisCall(RetId,DefArgNum,VaArgNum,isType,2))
    {
        if (RetId == -2)
            return CallUdtEntity(self,SARG(arg0,arg1));
        else if (isType)
        {
            if (RetId >= 0)  // none-init function
            {
                CseObj vFuncAddr = arg0;
                int ArgTp = CSE_TYPE(vFuncAddr);
                if ( (ArgTp == dtInt && vFuncAddr->iValue == 0xCCCCCCCC) || (ArgTp == dtStrong && CSE_TYPE(vFuncAddr->vValue) == dtBuff) )
                {   // init function address and call
                    _TEntity vFunc;
                    vFunc->Id_ = self->Id_;
                    vFunc->value = arg0;
                    return vFunc(SARG(arg1));
                }
                else throw NoInitFuncErr();
            }
            else
            {
                ASSERT_TRUE(RetId == -1);
                return CreateUdtComponent(self,SARG(arg0,arg1));
            }
        }

        if (DefArgNum > 0 || NEED_VA(VaArgNum,arg1))
            return CallVaArgCdeclFunc(self,DefArgNum,VaArgNum,SARG(arg0,arg1));

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            ((void (*)(const TCseObj&,const TCseObj&)) func)(arg0,arg1); 
            return dummy;
        }
        else if (RetId == 1)
            return ((TCseObj (*)(const TCseObj&,const TCseObj&)) func)(arg0,arg1); 
        else if (RetId == 2)
            return ((TIntObj (*)(const TCseObj&,const TCseObj&)) func)(arg0,arg1); 
        else if (RetId == 3)
            return ((TCharArray (*)(const TCseObj&,const TCseObj&)) func)(arg0,arg1); 
        else if (RetId == 4)
            return ((TIntArray (*)(const TCseObj&,const TCseObj&)) func)(arg0,arg1); 
        else if (RetId == 5)
            return ((TObjArray (*)(const TCseObj&,const TCseObj&)) func)(arg0,arg1); 
        else if (RetId == 6)
            return ((TEntryArray (*)(const TCseObj&,const TCseObj&)) func)(arg0,arg1); 
        else if (RetId == 7)
            return ((TWintObj (*)(const TCseObj&,const TCseObj&)) func)(arg0,arg1); 
        else // if (RetId == 8)
            return ((TFloatObj (*)(const TCseObj&,const TCseObj&)) func)(arg0,arg1); 
    }
    else
    {
        if (DefArgNum > 0 || NEED_VA(VaArgNum,arg1))
            return CallVaArgThiscallFunc(self,arg0,DefArgNum,VaArgNum,SARG(arg1));

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            union {
                void (TCseObj::* method)(const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            (((TCseObj*)&arg0)->* AMethod.method)(arg1);
            return dummy;
        }
        else if (RetId == 1)
        {
            union {
                TCseObj (TCseObj::* method)(const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1);
        }
        else if (RetId == 2)
        {
            union {
                TIntObj (TCseObj::* method)(const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1);
        }
        else if (RetId == 3)
        {
            union {
                TCharArray (TCseObj::* method)(const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1);
        }
        else if (RetId == 4)
        {
            union {
                TIntArray (TCseObj::* method)(const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1);
        }
        else if (RetId == 5)
        {
            union {
                TObjArray (TCseObj::* method)(const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1);
        }
        else if (RetId == 6)
        {
            union {
                TEntryArray (TCseObj::* method)(const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1);
        }
        else if (RetId == 7)
        {
            union {
                TWintObj (TCseObj::* method)(const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1);
        }
        else // if (RetId == 8)
        {
            union {
                TFloatObj (TCseObj::* method)(const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1);
        }
    }
}

TCseObj _TEntity::operator()(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2) const
{
    TInt RetId = 0;     // void v i s t b d w f
    TInt DefArgNum = 0;
    TInt VaArgNum = 0;
    TBool isType;
    if (! isThisCall(RetId,DefArgNum,VaArgNum,isType,3))
    {
        if (RetId == -2)
            return CallUdtEntity(self,SARG(arg0,arg1,arg2));
        else if (isType)
        {
            if (RetId >= 0)  // none-init function
            {
                CseObj vFuncAddr = arg0;
                int ArgTp = CSE_TYPE(vFuncAddr);
                if ( (ArgTp == dtInt && vFuncAddr->iValue == 0xCCCCCCCC) || (ArgTp == dtStrong && CSE_TYPE(vFuncAddr->vValue) == dtBuff) )
                {   // init function address and call
                    _TEntity vFunc;
                    vFunc->Id_ = self->Id_;
                    vFunc->value = arg0;
                    return vFunc(SARG(arg1,arg2));
                }
                else throw NoInitFuncErr();
            }
            else
            {
                ASSERT_TRUE(RetId == -1);
                return CreateUdtComponent(self,SARG(arg0,arg1,arg2));
            }
        }

        if (DefArgNum > 0 || NEED_VA(VaArgNum,arg2))
            return CallVaArgCdeclFunc(self,DefArgNum,VaArgNum,SARG(arg0,arg1,arg2));

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            ((void (*)(const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2);
            return dummy;
        }
        else if (RetId == 1)
            return ((TCseObj (*)(const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2); 
        else if (RetId == 2)
            return ((TIntObj (*)(const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2); 
        else if (RetId == 3)
            return ((TCharArray (*)(const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2); 
        else if (RetId == 4)
            return ((TIntArray (*)(const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2); 
        else if (RetId == 5)
            return ((TObjArray (*)(const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2); 
        else if (RetId == 6)
            return ((TEntryArray (*)(const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2); 
        else if (RetId == 7)
            return ((TWintObj (*)(const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2); 
        else // if (RetId == 8)
            return ((TFloatObj (*)(const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2); 
    }
    else
    {
        if (DefArgNum > 0 || NEED_VA(VaArgNum,arg2))
            return CallVaArgThiscallFunc(self,arg0,DefArgNum,VaArgNum,SARG(arg1,arg2));

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            union {
                void (TCseObj::* method)(const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2);
            return dummy;
        }
        else if (RetId == 1)
        {
            union {
                TCseObj (TCseObj::* method)(const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2);
        }
        else if (RetId == 2)
        {
            union {
                TIntObj (TCseObj::* method)(const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2);
        }
        else if (RetId == 3)
        {
            union {
                TCharArray (TCseObj::* method)(const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2);
        }
        else if (RetId == 4)
        {
            union {
                TIntArray (TCseObj::* method)(const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2);
        }
        else if (RetId == 5)
        {
            union {
                TObjArray (TCseObj::* method)(const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2);
        }
        else if (RetId == 6)
        {
            union {
                TEntryArray (TCseObj::* method)(const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2);
        }
        else if (RetId == 7)
        {
            union {
                TWintObj (TCseObj::* method)(const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2);
        }
        else // if (RetId == 8)
        {
            union {
                TFloatObj (TCseObj::* method)(const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2);
        }
    }
}

TCseObj _TEntity::operator()(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3) const
{
    TInt RetId = 0;     // void v i s t b d w f
    TInt DefArgNum = 0;
    TInt VaArgNum = 0;
    TBool isType;
    if (! isThisCall(RetId,DefArgNum,VaArgNum,isType,4))
    {
        if (RetId == -2)
            return CallUdtEntity(self,SARG(arg0,arg1,arg2,arg3));
        else if (isType)
        {
            if (RetId >= 0)  // none-init function
            {
                CseObj vFuncAddr = arg0;
                int ArgTp = CSE_TYPE(vFuncAddr);
                if ( (ArgTp == dtInt && vFuncAddr->iValue == 0xCCCCCCCC) || (ArgTp == dtStrong && CSE_TYPE(vFuncAddr->vValue) == dtBuff) )
                {   // init function address and call
                    _TEntity vFunc;
                    vFunc->Id_ = self->Id_;
                    vFunc->value = arg0;
                    return vFunc(SARG(arg1,arg2,arg3));
                }
                else throw NoInitFuncErr();
            }
            else
            {
                ASSERT_TRUE(RetId == -1);
                return CreateUdtComponent(self,SARG(arg0,arg1,arg2,arg3));
            }
        }

        if (DefArgNum > 0 || NEED_VA(VaArgNum,arg3))
            return CallVaArgCdeclFunc(self,DefArgNum,VaArgNum,SARG(arg0,arg1,arg2,arg3));

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            ((void (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3);
            return dummy;
        }
        else if (RetId == 1)
            return ((TCseObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3);
        else if (RetId == 2)
            return ((TIntObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3);
        else if (RetId == 3)
            return ((TCharArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3);
        else if (RetId == 4)
            return ((TIntArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3);
        else if (RetId == 5)
            return ((TObjArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3);
        else if (RetId == 6)
            return ((TEntryArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3);
        else if (RetId == 7)
            return ((TWintObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3);
        else // if (RetId == 8)
            return ((TFloatObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3);
    }
    else
    {
        if (DefArgNum > 0 || NEED_VA(VaArgNum,arg3))
            return CallVaArgThiscallFunc(self,arg0,DefArgNum,VaArgNum,SARG(arg1,arg2,arg3));

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            union {
                void (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3);
            return dummy;
        }
        else if (RetId == 1)
        {
            union {
                TCseObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3);
        }
        else if (RetId == 2)
        {
            union {
                TIntObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3);
        }
        else if (RetId == 3)
        {
            union {
                TCharArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3);
        }
        else if (RetId == 4)
        {
            union {
                TIntArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3);
        }
        else if (RetId == 5)
        {
            union {
                TObjArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3);
        }
        else if (RetId == 6)
        {
            union {
                TEntryArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3);
        }
        else if (RetId == 7)
        {
            union {
                TWintObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3);
        }
        else // if (RetId == 8)
        {
            union {
                TFloatObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3);
        }
    }
}

TCseObj _TEntity::operator()(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4) const
{
    TInt RetId = 0;     // void v i s t b d w f
    TInt DefArgNum = 0;
    TInt VaArgNum = 0;
    TBool isType;
    if (! isThisCall(RetId,DefArgNum,VaArgNum,isType,5))
    {
        if (RetId == -2)
            return CallUdtEntity(self,SARG(arg0,arg1,arg2,arg3,arg4));
        else if (isType)
        {
            if (RetId >= 0)  // none-init function
            {
                CseObj vFuncAddr = arg0;
                int ArgTp = CSE_TYPE(vFuncAddr);
                if ( (ArgTp == dtInt && vFuncAddr->iValue == 0xCCCCCCCC) || (ArgTp == dtStrong && CSE_TYPE(vFuncAddr->vValue) == dtBuff) )
                {   // init function address and call
                    _TEntity vFunc;
                    vFunc->Id_ = self->Id_;
                    vFunc->value = arg0;
                    return vFunc(SARG(arg1,arg2,arg3,arg4));
                }
                else throw NoInitFuncErr();
            }
            else
            {
                ASSERT_TRUE(RetId == -1);
                return CreateUdtComponent(self,SARG(arg0,arg1,arg2,arg3,arg4));
            }
        }

        if (DefArgNum > 0 || NEED_VA(VaArgNum,arg4))
            return CallVaArgCdeclFunc(self,DefArgNum,VaArgNum,SARG(arg0,arg1,arg2,arg3,arg4));

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            ((void (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4); 
            return dummy;
        }
        else if (RetId == 1)
            return ((TCseObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4); 
        else if (RetId == 2)
            return ((TIntObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4); 
        else if (RetId == 3)
            return ((TCharArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4); 
        else if (RetId == 4)
            return ((TIntArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4); 
        else if (RetId == 5)
            return ((TObjArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4); 
        else if (RetId == 6)
            return ((TEntryArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4); 
        else if (RetId == 7)
            return ((TWintObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4); 
        else // if (RetId == 8)
            return ((TFloatObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4); 
    }
    else
    {
        if (DefArgNum > 0 || NEED_VA(VaArgNum,arg4))
            return CallVaArgThiscallFunc(self,arg0,DefArgNum,VaArgNum,SARG(arg1,arg2,arg3,arg4));

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            union {
                void (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4);
            return dummy;
        }
        else if (RetId == 1)
        {
            union {
                TCseObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4);
        }
        else if (RetId == 2)
        {
            union {
                TIntObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4);
        }
        else if (RetId == 3)
        {
            union {
                TCharArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4);
        }
        else if (RetId == 4)
        {
            union {
                TIntArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4);
        }
        else if (RetId == 5)
        {
            union {
                TObjArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4);
        }
        else if (RetId == 6)
        {
            union {
                TEntryArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4);
        }
        else if (RetId == 7)
        {
            union {
                TWintObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4);
        }
        else // if (RetId == 8)
        {
            union {
                TFloatObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4);
        }
    }
}

TCseObj _TEntity::operator()(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5) const
{
    TInt RetId = 0;     // void v i s t b d w f
    TInt DefArgNum = 0;
    TInt VaArgNum = 0;
    TBool isType;
    if (! isThisCall(RetId,DefArgNum,VaArgNum,isType,6))
    {
        if (RetId == -2)
            return CallUdtEntity(self,SARG(arg0,arg1,arg2,arg3,arg4,arg5));
        else if (isType)
        {
            if (RetId >= 0)  // none-init function
            {
                CseObj vFuncAddr = arg0;
                int ArgTp = CSE_TYPE(vFuncAddr);
                if ( (ArgTp == dtInt && vFuncAddr->iValue == 0xCCCCCCCC) || (ArgTp == dtStrong && CSE_TYPE(vFuncAddr->vValue) == dtBuff) )
                {   // init function address and call
                    _TEntity vFunc;
                    vFunc->Id_ = self->Id_;
                    vFunc->value = arg0;
                    return vFunc(SARG(arg1,arg2,arg3,arg4,arg5));
                }
                else throw NoInitFuncErr();
            }
            else
            {
                ASSERT_TRUE(RetId == -1);
                return CreateUdtComponent(self,SARG(arg0,arg1,arg2,arg3,arg4,arg5));
            }
        }

        if (DefArgNum > 0 || NEED_VA(VaArgNum,arg5))
            return CallVaArgCdeclFunc(self,DefArgNum,VaArgNum,SARG(arg0,arg1,arg2,arg3,arg4,arg5));

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            ((void (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5);
            return dummy;
        }
        else if (RetId == 1)
            return ((TCseObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5); 
        else if (RetId == 2)
            return ((TIntObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5); 
        else if (RetId == 3)
            return ((TCharArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5); 
        else if (RetId == 4)
            return ((TIntArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5); 
        else if (RetId == 5)
            return ((TObjArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5); 
        else if (RetId == 6)
            return ((TEntryArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5); 
        else if (RetId == 7)
            return ((TWintObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5); 
        else // if (RetId == 8)
            return ((TFloatObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5); 
    }
    else
    {
        if (DefArgNum > 0 || NEED_VA(VaArgNum,arg5))
            return CallVaArgThiscallFunc(self,arg0,DefArgNum,VaArgNum,SARG(arg1,arg2,arg3,arg4,arg5));

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            union {
                void (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5);
            return dummy;
        }
        else if (RetId == 1)
        {
            union {
                TCseObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5);
        }
        else if (RetId == 2)
        {
            union {
                TIntObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5);
        }
        else if (RetId == 3)
        {
            union {
                TCharArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5);
        }
        else if (RetId == 4)
        {
            union {
                TIntArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5);
        }
        else if (RetId == 5)
        {
            union {
                TObjArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5);
        }
        else if (RetId == 6)
        {
            union {
                TEntryArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5);
        }
        else if (RetId == 7)
        {
            union {
                TWintObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5);
        }
        else // if (RetId == 8)
        {
            union {
                TFloatObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5);
        }
    }
}

TCseObj _TEntity::operator()(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6) const
{
    TInt RetId = 0;     // void v i s t b d w f
    TInt DefArgNum = 0;
    TInt VaArgNum = 0;
    TBool isType;
    if (! isThisCall(RetId,DefArgNum,VaArgNum,isType,7))
    {
        if (RetId == -2)
            return CallUdtEntity(self,SARG(arg0,arg1,arg2,arg3,arg4,arg5,arg6));
        else if (isType)
        {
            if (RetId >= 0)  // none-init function
            {
                CseObj vFuncAddr = arg0;
                int ArgTp = CSE_TYPE(vFuncAddr);
                if ( (ArgTp == dtInt && vFuncAddr->iValue == 0xCCCCCCCC) || (ArgTp == dtStrong && CSE_TYPE(vFuncAddr->vValue) == dtBuff) )
                {   // init function address and call
                    _TEntity vFunc;
                    vFunc->Id_ = self->Id_;
                    vFunc->value = arg0;
                    return vFunc(SARG(arg1,arg2,arg3,arg4,arg5,arg6));
                }
                else throw NoInitFuncErr();
            }
            else
            {
                ASSERT_TRUE(RetId == -1);
                return CreateUdtComponent(self,SARG(arg0,arg1,arg2,arg3,arg4,arg5,arg6));
            }
        }

        if (DefArgNum > 0 || NEED_VA(VaArgNum,arg6))
            return CallVaArgCdeclFunc(self,DefArgNum,VaArgNum,SARG(arg0,arg1,arg2,arg3,arg4,arg5,arg6));

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            ((void (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6);
            return dummy;
        }
        else if (RetId == 1)
            return ((TCseObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6);
        else if (RetId == 2)
            return ((TIntObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6);
        else if (RetId == 3)
            return ((TCharArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6);
        else if (RetId == 4)
            return ((TIntArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6);
        else if (RetId == 5)
            return ((TObjArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6);
        else if (RetId == 6)
            return ((TEntryArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6);
        else if (RetId == 7)
            return ((TWintObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6);
        else // if (RetId == 8)
            return ((TFloatObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6);
    }
    else
    {
        if (DefArgNum > 0 || NEED_VA(VaArgNum,arg6))
            return CallVaArgThiscallFunc(self,arg0,DefArgNum,VaArgNum,SARG(arg1,arg2,arg3,arg4,arg5,arg6));

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            union {
                void (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6);
            return dummy;
        }
        else if (RetId == 1)
        {
            union {
                TCseObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6);
        }
        else if (RetId == 2)
        {
            union {
                TIntObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6);
        }
        else if (RetId == 3)
        {
            union {
                TCharArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6);
        }
        else if (RetId == 4)
        {
            union {
                TIntArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6);
        }
        else if (RetId == 5)
        {
            union {
                TObjArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6);
        }
        else if (RetId == 6)
        {
            union {
                TEntryArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6);
        }
        else if (RetId == 7)
        {
            union {
                TWintObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6);
        }
        else // if (RetId == 8)
        {
            union {
                TFloatObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6);
        }
    }
}

TCseObj _TEntity::operator()(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7) const
{
    TInt RetId = 0;     // void v i s t b d w f
    TInt DefArgNum = 0;
    TInt VaArgNum = 0;
    TBool isType;
    if (! isThisCall(RetId,DefArgNum,VaArgNum,isType,8))
    {
        if (RetId == -2)
            return CallUdtEntity(self,SARG(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7));
        else if (isType)
        {
            if (RetId >= 0)  // none-init function
            {
                CseObj vFuncAddr = arg0;
                int ArgTp = CSE_TYPE(vFuncAddr);
                if ( (ArgTp == dtInt && vFuncAddr->iValue == 0xCCCCCCCC) || (ArgTp == dtStrong && CSE_TYPE(vFuncAddr->vValue) == dtBuff) )
                {   // init function address and call
                    _TEntity vFunc;
                    vFunc->Id_ = self->Id_;
                    vFunc->value = arg0;
                    return vFunc(SARG(arg1,arg2,arg3,arg4,arg5,arg6,arg7));
                }
                else throw NoInitFuncErr();
            }
            else
            {
                ASSERT_TRUE(RetId == -1);
                return CreateUdtComponent(self,SARG(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7));
            }
        }

        if (DefArgNum > 0 || NEED_VA(VaArgNum,arg7))
            return CallVaArgCdeclFunc(self,DefArgNum,VaArgNum,SARG(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7));

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            ((void (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7);
            return dummy;
        }
        else if (RetId == 1)
            return ((TCseObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7); 
        else if (RetId == 2)
            return ((TIntObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7); 
        else if (RetId == 3)
            return ((TCharArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7); 
        else if (RetId == 4)
            return ((TIntArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7); 
        else if (RetId == 5)
            return ((TObjArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7); 
        else if (RetId == 6)
            return ((TEntryArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7); 
        else if (RetId == 7)
            return ((TWintObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7); 
        else // if (RetId == 8)
            return ((TFloatObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7); 
    }
    else
    {
        if (DefArgNum > 0 || NEED_VA(VaArgNum,arg7))
            return CallVaArgThiscallFunc(self,arg0,DefArgNum,VaArgNum,SARG(arg1,arg2,arg3,arg4,arg5,arg6,arg7));

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            union {
                void (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7);
            return dummy;
        }
        else if (RetId == 1)
        {
            union {
                TCseObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7);
        }
        else if (RetId == 2)
        {
            union {
                TIntObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7);
        }
        else if (RetId == 3)
        {
            union {
                TCharArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7);
        }
        else if (RetId == 4)
        {
            union {
                TIntArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7);
        }
        else if (RetId == 5)
        {
            union {
                TObjArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7);
        }
        else if (RetId == 6)
        {
            union {
                TEntryArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7);
        }
        else if (RetId == 7)
        {
            union {
                TWintObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7);
        }
        else // if (RetId == 8)
        {
            union {
                TFloatObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7);
        }
    }
}

TCseObj _TEntity::operator()(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8) const
{
    TInt RetId = 0;     // void v i s t b d w f
    TInt DefArgNum = 0;
    TInt VaArgNum = 0;
    TBool isType;
    if (! isThisCall(RetId,DefArgNum,VaArgNum,isType,9))
    {
        if (RetId == -2)
            return CallUdtEntity(self,SARG(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8));
        else if (isType)
        {
            if (RetId >= 0)  // none-init function
            {
                CseObj vFuncAddr = arg0;
                int ArgTp = CSE_TYPE(vFuncAddr);
                if ( (ArgTp == dtInt && vFuncAddr->iValue == 0xCCCCCCCC) || (ArgTp == dtStrong && CSE_TYPE(vFuncAddr->vValue) == dtBuff) )
                {   // init function address and call
                    _TEntity vFunc;
                    vFunc->Id_ = self->Id_;
                    vFunc->value = arg0;
                    return vFunc(SARG(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8));
                }
                else throw NoInitFuncErr();
            }
            else
            {
                ASSERT_TRUE(RetId == -1);
                return CreateUdtComponent(self,SARG(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8));
            }
        }

        if (DefArgNum > 0 || NEED_VA(VaArgNum,arg8))
            return CallVaArgCdeclFunc(self,DefArgNum,VaArgNum,SARG(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8));

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            ((void (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); 
            return dummy;
        }
        else if (RetId == 1)
            return ((TCseObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); 
        else if (RetId == 2)
            return ((TIntObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); 
        else if (RetId == 3)
            return ((TCharArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); 
        else if (RetId == 4)
            return ((TIntArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); 
        else if (RetId == 5)
            return ((TObjArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); 
        else if (RetId == 6)
            return ((TEntryArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); 
        else if (RetId == 7)
            return ((TWintObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); 
        else // if (RetId == 8)
            return ((TFloatObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); 
    }
    else
    {
        if (DefArgNum > 0 || NEED_VA(VaArgNum,arg8))
            return CallVaArgThiscallFunc(self,arg0,DefArgNum,VaArgNum,SARG(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8));

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            union {
                void (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);
            return dummy;
        }
        else if (RetId == 1)
        {
            union {
                TCseObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);
        }
        else if (RetId == 2)
        {
            union {
                TIntObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);
        }
        else if (RetId == 3)
        {
            union {
                TCharArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);
        }
        else if (RetId == 4)
        {
            union {
                TIntArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);
        }
        else if (RetId == 5)
        {
            union {
                TObjArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);
        }
        else if (RetId == 6)
        {
            union {
                TEntryArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);
        }
        else if (RetId == 7)
        {
            union {
                TWintObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);
        }
        else // if (RetId == 8)
        {
            union {
                TFloatObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);
        }
    }
}

TCseObj _TEntity::operator()(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8,const TCseObj& arg9) const
{
    TInt RetId = 0;     // void v i s t b d w f
    TInt DefArgNum = 0;
    TInt VaArgNum = 0;
    TBool isType;
    if (! isThisCall(RetId,DefArgNum,VaArgNum,isType,10))
    {
        if (RetId == -2)
            return CallUdtEntity(self,SARG(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9));
        else if (isType)
        {
            if (RetId >= 0)  // none-init function
            {
                CseObj vFuncAddr = arg0;
                int ArgTp = CSE_TYPE(vFuncAddr);
                if ( (ArgTp == dtInt && vFuncAddr->iValue == 0xCCCCCCCC) || (ArgTp == dtStrong && CSE_TYPE(vFuncAddr->vValue) == dtBuff) )
                {   // init function address and call
                    _TEntity vFunc;
                    vFunc->Id_ = self->Id_;
                    vFunc->value = arg0;
                    return vFunc(SARG(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9));
                }
                else throw NoInitFuncErr();
            }
            else
            {
                ASSERT_TRUE(RetId == -1);
                return CreateUdtComponent(self,SARG(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9));
            }
        }

        if (DefArgNum > 0 || NEED_VA(VaArgNum,arg9))
            return CallVaArgCdeclFunc(self,DefArgNum,VaArgNum,SARG(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9));

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            ((void (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
            return dummy;
        }
        else if (RetId == 1)
            return ((TCseObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
        else if (RetId == 2)
            return ((TIntObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
        else if (RetId == 3)
            return ((TCharArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
        else if (RetId == 4)
            return ((TIntArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
        else if (RetId == 5)
            return ((TObjArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
        else if (RetId == 6)
            return ((TEntryArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
        else if (RetId == 7)
            return ((TWintObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
        else // if (RetId == 8)
            return ((TFloatObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
    }
    else
    {
        if (DefArgNum > 0 || NEED_VA(VaArgNum,arg9))
            return CallVaArgThiscallFunc(self,arg0,DefArgNum,VaArgNum,SARG(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9));

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            union {
                void (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
            return dummy;
        }
        else if (RetId == 1)
        {
            union {
                TCseObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
        }
        else if (RetId == 2)
        {
            union {
                TIntObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
        }
        else if (RetId == 3)
        {
            union {
                TCharArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
        }
        else if (RetId == 4)
        {
            union {
                TIntArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
        }
        else if (RetId == 5)
        {
            union {
                TObjArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
        }
        else if (RetId == 6)
        {
            union {
                TEntryArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
        }
        else if (RetId == 7)
        {
            union {
                TWintObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
        }
        else // if (RetId == 8)
        {
            union {
                TFloatObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
        }
    }
}

TCseObj _TEntity::operator()(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8,const TCseObj& arg9,const TCseObj& arg10) const
{
    TInt RetId = 0;     // void v i s t b d w f
    TInt DefArgNum = 0;
    TInt VaArgNum = 0;
    TBool isType;
    if (! isThisCall(RetId,DefArgNum,VaArgNum,isType,11))
    {
        if (RetId == -2)
            return CallUdtEntity(self,SARG(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10));
        else if (isType)
        {
            if (RetId >= 0)  // none-init function
            {
                CseObj vFuncAddr = arg0;
                int ArgTp = CSE_TYPE(vFuncAddr);
                if ( (ArgTp == dtInt && vFuncAddr->iValue == 0xCCCCCCCC) || (ArgTp == dtStrong && CSE_TYPE(vFuncAddr->vValue) == dtBuff) )
                {   // init function address and call
                    _TEntity vFunc;
                    vFunc->Id_ = self->Id_;
                    vFunc->value = arg0;
                    return vFunc(SARG(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10));
                }
                else throw NoInitFuncErr();
            }
            else
            {
                ASSERT_TRUE(RetId == -1);
                return CreateUdtComponent(self,SARG(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10));
            }
        }

        if (DefArgNum > 0 || NEED_VA(VaArgNum,arg10))
            return CallVaArgCdeclFunc(self,DefArgNum,VaArgNum,SARG(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10));

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            ((void (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
            return dummy;
        }
        else if (RetId == 1)
            return ((TCseObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
        else if (RetId == 2)
            return ((TIntObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
        else if (RetId == 3)
            return ((TCharArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
        else if (RetId == 4)
            return ((TIntArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
        else if (RetId == 5)
            return ((TObjArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
        else if (RetId == 6)
            return ((TEntryArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
        else if (RetId == 7)
            return ((TWintObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
        else // if (RetId == 8)
            return ((TFloatObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
    }
    else
    {
        if (DefArgNum > 0 || NEED_VA(VaArgNum,arg10))
            return CallVaArgThiscallFunc(self,arg0,DefArgNum,VaArgNum,SARG(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10));

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            union {
                void (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
            return dummy;
        }
        else if (RetId == 1)
        {
            union {
                TCseObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
        }
        else if (RetId == 2)
        {
            union {
                TIntObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
        }
        else if (RetId == 3)
        {
            union {
                TCharArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
        }
        else if (RetId == 4)
        {
            union {
                TIntArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
        }
        else if (RetId == 5)
        {
            union {
                TObjArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
        }
        else if (RetId == 6)
        {
            union {
                TEntryArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
        }
        else if (RetId == 7)
        {
            union {
                TWintObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
        }
        else // if (RetId == 8)
        {
            union {
                TFloatObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
        }
    }
}

TCseObj _TEntity::operator()(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8,const TCseObj& arg9,const TCseObj& arg10,const TCseObj& arg11) const
{
    TInt RetId = 0;     // void v i s t b d w f
    TInt DefArgNum = 0;
    TInt VaArgNum = 0;
    TBool isType;
    if (! isThisCall(RetId,DefArgNum,VaArgNum,isType,12))
    {
        if (RetId == -2)
            return CallUdtEntity(self,SARG(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11));
        else if (isType)
        {
            if (RetId >= 0)  // none-init function
            {
                CseObj vFuncAddr = arg0;
                int ArgTp = CSE_TYPE(vFuncAddr);
                if ( (ArgTp == dtInt && vFuncAddr->iValue == 0xCCCCCCCC) || (ArgTp == dtStrong && CSE_TYPE(vFuncAddr->vValue) == dtBuff) )
                {   // init function address and call
                    _TEntity vFunc;
                    vFunc->Id_ = self->Id_;
                    vFunc->value = arg0;
                    return vFunc(SARG(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11));
                }
                else throw NoInitFuncErr();
            }
            else
            {
                ASSERT_TRUE(RetId == -1);
                return CreateUdtComponent(self,SARG(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11));
            }
        }

        if (DefArgNum > 0 || NEED_VA(VaArgNum,arg11))
            return CallVaArgCdeclFunc(self,DefArgNum,VaArgNum,SARG(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11));

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            ((void (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11);
            return dummy;
        }
        else if (RetId == 1)
            return ((TCseObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11);
        else if (RetId == 2)
            return ((TIntObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11);
        else if (RetId == 3)
            return ((TCharArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11);
        else if (RetId == 4)
            return ((TIntArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11);
        else if (RetId == 5)
            return ((TObjArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11);
        else if (RetId == 6)
            return ((TEntryArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11);
        else if (RetId == 7)
            return ((TWintObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11);
        else // if (RetId == 8)
            return ((TFloatObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11);
    }
    else
    {
        if (DefArgNum > 0 || NEED_VA(VaArgNum,arg11))
            return CallVaArgThiscallFunc(self,arg0,DefArgNum,VaArgNum,SARG(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11));

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            union {
                void (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11);
            return dummy;
        }
        else if (RetId == 1)
        {
            union {
                TCseObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11);
        }
        else if (RetId == 2)
        {
            union {
                TIntObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11);
        }
        else if (RetId == 3)
        {
            union {
                TCharArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11);
        }
        else if (RetId == 4)
        {
            union {
                TIntArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11);
        }
        else if (RetId == 5)
        {
            union {
                TObjArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11);
        }
        else if (RetId == 6)
        {
            union {
                TEntryArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11);
        }
        else if (RetId == 7)
        {
            union {
                TWintObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11);
        }
        else // if (RetId == 8)
        {
            union {
                TFloatObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11);
        }
    }
}

TCseObj _TEntity::operator()(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8,const TCseObj& arg9,const TCseObj& arg10,const TCseObj& arg11,const TCseObj& arg12) const
{
    TInt RetId = 0;     // void v i s t b d w f
    TInt DefArgNum = 0;
    TInt VaArgNum = 0;
    TBool isType;
    if (! isThisCall(RetId,DefArgNum,VaArgNum,isType,13))
    {
        if (RetId == -2)
            return CallUdtEntity(self,SARG(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12));
        else if (isType)
        {
            if (RetId >= 0)  // none-init function
            {
                CseObj vFuncAddr = arg0;
                int ArgTp = CSE_TYPE(vFuncAddr);
                if ( (ArgTp == dtInt && vFuncAddr->iValue == 0xCCCCCCCC) || (ArgTp == dtStrong && CSE_TYPE(vFuncAddr->vValue) == dtBuff) )
                {   // init function address and call
                    _TEntity vFunc;
                    vFunc->Id_ = self->Id_;
                    vFunc->value = arg0;
                    return vFunc(SARG(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12));
                }
                else throw NoInitFuncErr();
            }
            else
            {
                ASSERT_TRUE(RetId == -1);
                return CreateUdtComponent(self,SARG(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12));
            }
        }

        if (DefArgNum > 0 || NEED_VA(VaArgNum,arg12))
            return CallVaArgCdeclFunc(self,DefArgNum,VaArgNum,SARG(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12));

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            ((void (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12);
            return dummy;
        }
        else if (RetId == 1)
            return ((TCseObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12);
        else if (RetId == 2)
            return ((TIntObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12);
        else if (RetId == 3)
            return ((TCharArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12);
        else if (RetId == 4)
            return ((TIntArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12);
        else if (RetId == 5)
            return ((TObjArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12);
        else if (RetId == 6)
            return ((TEntryArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12);
        else if (RetId == 7)
            return ((TWintObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12);
        else // if (RetId == 8)
            return ((TFloatObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12);
    }
    else
    {
        if (DefArgNum > 0 || NEED_VA(VaArgNum,arg12))
            return CallVaArgThiscallFunc(self,arg0,DefArgNum,VaArgNum,SARG(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12));

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            union {
                void (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12);
            return dummy;
        }
        else if (RetId == 1)
        {
            union {
                TCseObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12);
        }
        else if (RetId == 2)
        {
            union {
                TIntObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12);
        }
        else if (RetId == 3)
        {
            union {
                TCharArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12);
        }
        else if (RetId == 4)
        {
            union {
                TIntArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12);
        }
        else if (RetId == 5)
        {
            union {
                TObjArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12);
        }
        else if (RetId == 6)
        {
            union {
                TEntryArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12);
        }
        else if (RetId == 7)
        {
            union {
                TWintObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12);
        }
        else // if (RetId == 8)
        {
            union {
                TFloatObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12);
        }
    }
}

TCseObj _TEntity::operator()(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8,const TCseObj& arg9,const TCseObj& arg10,const TCseObj& arg11,const TCseObj& arg12,const TCseObj& arg13) const
{
    TInt RetId = 0;     // void v i s t b d w f
    TInt DefArgNum = 0;
    TInt VaArgNum = 0;
    TBool isType;
    if (! isThisCall(RetId,DefArgNum,VaArgNum,isType,14))
    {
        if (RetId == -2)
            return CallUdtEntity(self,SARG(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13));
        else if (isType)
        {
            if (RetId >= 0)  // none-init function
            {
                CseObj vFuncAddr = arg0;
                int ArgTp = CSE_TYPE(vFuncAddr);
                if ( (ArgTp == dtInt && vFuncAddr->iValue == 0xCCCCCCCC) || (ArgTp == dtStrong && CSE_TYPE(vFuncAddr->vValue) == dtBuff) )
                {   // init function address and call
                    _TEntity vFunc;
                    vFunc->Id_ = self->Id_;
                    vFunc->value = arg0;
                    return vFunc(SARG(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13));
                }
                else throw NoInitFuncErr();
            }
            else
            {
                ASSERT_TRUE(RetId == -1);
                return CreateUdtComponent(self,SARG(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13));
            }
        }

        if (DefArgNum > 0 || NEED_VA(VaArgNum,arg13))
            return CallVaArgCdeclFunc(self,DefArgNum,VaArgNum,SARG(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13));

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            ((void (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13);
            return dummy;
        }
        else if (RetId == 1)
            return ((TCseObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13);
        else if (RetId == 2)
            return ((TIntObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13);
        else if (RetId == 3)
            return ((TCharArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13);
        else if (RetId == 4)
            return ((TIntArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13);
        else if (RetId == 5)
            return ((TObjArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13);
        else if (RetId == 6)
            return ((TEntryArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13);
        else if (RetId == 7)
            return ((TWintObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13);
        else // if (RetId == 8)
            return ((TFloatObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13);
    }
    else
    {
        if (DefArgNum > 0 || NEED_VA(VaArgNum,arg13))
            return CallVaArgThiscallFunc(self,arg0,DefArgNum,VaArgNum,SARG(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13));

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            union {
                void (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13);
            return dummy;
        }
        else if (RetId == 1)
        {
            union {
                TCseObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13);
        }
        else if (RetId == 2)
        {
            union {
                TIntObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13);
        }
        else if (RetId == 3)
        {
            union {
                TCharArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13);
        }
        else if (RetId == 4)
        {
            union {
                TIntArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13);
        }
        else if (RetId == 5)
        {
            union {
                TObjArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13);
        }
        else if (RetId == 6)
        {
            union {
                TEntryArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13);
        }
        else if (RetId == 7)
        {
            union {
                TWintObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13);
        }
        else // if (RetId == 8)
        {
            union {
                TFloatObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13);
        }
    }
}

TCseObj _TEntity::operator()(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8,const TCseObj& arg9,const TCseObj& arg10,const TCseObj& arg11,const TCseObj& arg12,const TCseObj& arg13,const TCseObj& arg14) const
{
    TInt RetId = 0;     // void v i s t b d w f
    TInt DefArgNum = 0;
    TInt VaArgNum = 0;
    TBool isType;
    if (! isThisCall(RetId,DefArgNum,VaArgNum,isType,15))
    {
        if (RetId == -2)
            return CallUdtEntity(self,SARG(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14));
        else if (isType)
        {
            if (RetId >= 0)  // none-init function
            {
                CseObj vFuncAddr = arg0;
                int ArgTp = CSE_TYPE(vFuncAddr);
                if ( (ArgTp == dtInt && vFuncAddr->iValue == 0xCCCCCCCC) || (ArgTp == dtStrong && CSE_TYPE(vFuncAddr->vValue) == dtBuff) )
                {   // init function address and call
                    _TEntity vFunc;
                    vFunc->Id_ = self->Id_;
                    vFunc->value = arg0;
                    return vFunc(SARG(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14));
                }
                else throw NoInitFuncErr();
            }
            else
            {
                ASSERT_TRUE(RetId == -1);
                return CreateUdtComponent(self,SARG(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14));
            }
        }

        if (DefArgNum > 0 || NEED_VA(VaArgNum,arg14))
            return CallVaArgCdeclFunc(self,DefArgNum,VaArgNum,SARG(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14));

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            ((void (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14);
            return dummy;
        }
        else if (RetId == 1)
            return ((TCseObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14);
        else if (RetId == 2)
            return ((TIntObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14);
        else if (RetId == 3)
            return ((TCharArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14);
        else if (RetId == 4)
            return ((TIntArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14);
        else if (RetId == 5)
            return ((TObjArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14);
        else if (RetId == 6)
            return ((TEntryArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14);
        else if (RetId == 7)
            return ((TWintObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14);
        else // if (RetId == 8)
            return ((TFloatObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14);
    }
    else
    {
        if (DefArgNum > 0 || NEED_VA(VaArgNum,arg14))
            return CallVaArgThiscallFunc(self,arg0,DefArgNum,VaArgNum,SARG(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14));

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            union {
                void (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14);
            return dummy;
        }
        else if (RetId == 1)
        {
            union {
                TCseObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14);
        }
        else if (RetId == 2)
        {
            union {
                TIntObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14);
        }
        else if (RetId == 3)
        {
            union {
                TCharArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14);
        }
        else if (RetId == 4)
        {
            union {
                TIntArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14);
        }
        else if (RetId == 5)
        {
            union {
                TObjArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14);
        }
        else if (RetId == 6)
        {
            union {
                TEntryArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14);
        }
        else if (RetId == 7)
        {
            union {
                TWintObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14);
        }
        else // if (RetId == 8)
        {
            union {
                TFloatObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14);
        }
    }
}

TCseObj _TEntity::operator()(const TCseObj& arg0,const TCseObj& arg1,const TCseObj& arg2,const TCseObj& arg3,const TCseObj& arg4,const TCseObj& arg5,const TCseObj& arg6,const TCseObj& arg7,const TCseObj& arg8,const TCseObj& arg9,const TCseObj& arg10,const TCseObj& arg11,const TCseObj& arg12,const TCseObj& arg13,const TCseObj& arg14,const TCseObj& arg15) const
{
    TInt RetId = 0;     // void v i s t b d w f
    TInt DefArgNum = 0;
    TInt VaArgNum = 0;
    TBool isType;
    if (! isThisCall(RetId,DefArgNum,VaArgNum,isType,16))
    {
        if (RetId == -2)
            return CallUdtEntity(self,SARG(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15));
        else if (isType)
        {
            if (RetId >= 0)  // none-init function
            {
                CseObj vFuncAddr = arg0;
                int ArgTp = CSE_TYPE(vFuncAddr);
                if ( (ArgTp == dtInt && vFuncAddr->iValue == 0xCCCCCCCC) || (ArgTp == dtStrong && CSE_TYPE(vFuncAddr->vValue) == dtBuff) )
                {   // init function address and call
                    _TEntity vFunc;
                    vFunc->Id_ = self->Id_;
                    vFunc->value = arg0;
                    return vFunc(SARG(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15));
                }
                else throw NoInitFuncErr();
            }
            else
            {
                ASSERT_TRUE(RetId == -1);
                return CreateUdtComponent(self,SARG(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15));
            }
        }

        if (DefArgNum > 0 || NEED_VA(VaArgNum,arg15))
            return CallVaArgCdeclFunc(self,DefArgNum,VaArgNum,SARG(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15));

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            ((void (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15);
            return dummy;
        }
        else if (RetId == 1)
            return ((TCseObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15);
        else if (RetId == 2)
            return ((TIntObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15);
        else if (RetId == 3)
            return ((TCharArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15);
        else if (RetId == 4)
            return ((TIntArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15);
        else if (RetId == 5)
            return ((TObjArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15);
        else if (RetId == 6)
            return ((TEntryArray (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15);
        else if (RetId == 7)
            return ((TWintObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15);
        else // if (RetId == 8)
            return ((TFloatObj (*)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&)) func)(arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15);
    }
    else
    {
        if (DefArgNum > 0 || NEED_VA(VaArgNum,arg15))
            return CallVaArgThiscallFunc(self,arg0,DefArgNum,VaArgNum,SARG(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15));

        void *func = (void*)self->value->iFlag;
        if (RetId == 0)
        {
            union {
                void (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15);
            return dummy;
        }
        else if (RetId == 1)
        {
            union {
                TCseObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15);
        }
        else if (RetId == 2)
        {
            union {
                TIntObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15);
        }
        else if (RetId == 3)
        {
            union {
                TCharArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15);
        }
        else if (RetId == 4)
        {
            union {
                TIntArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15);
        }
        else if (RetId == 5)
        {
            union {
                TObjArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15);
        }
        else if (RetId == 6)
        {
            union {
                TEntryArray (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15);
        }
        else if (RetId == 7)
        {
            union {
                TWintObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15);
        }
        else // if (RetId == 8)
        {
            union {
                TFloatObj (TCseObj::* method)(const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&,const TCseObj&);
                void *addr;
            } AMethod;
            AMethod.addr = func;
            return (((TCseObj*)&arg0)->* AMethod.method)(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12,arg13,arg14,arg15);
        }
    }
}

TIntObj _TEntity::eid() const
{
    ASSERT_TRUE(Cse_type(self->Id_) == dtBuff && Cse_OptionOn(self->Id_,16));

    CseObj CppEntity = self->value;
    if (CSE_TYPE(CppEntity) == dtBuff && CSE_ARRAY_LEN(CppEntity->bValue) > 0)
    {
        CseObj vId = CppEntity->bValue[0];
        if (CSE_TYPE(vId) == dtInt)
            return vId->iValue;
    }

    throw LOG_CSE_ERR(CSE_ATTR_ERR,_T("entity has no id() method"));
}

TIntObj _TEntity::has(const TCseObj& Attr) const
{
    CseObj bType = self->Id_;
    ASSERT_TRUE(CSE_TYPE(bType) == dtBuff && Cse_OptionOn(bType,16));

    TCseObj name = Attr.toId();
    _TEntity ret = CseSuper_EntityAttr(self,name,false);
    if (CseSuper_unknown != (CseObj)ret->Id_)  // UDT has member: Attr
        return 1;
    else return 0;
}

void _TEntity::exit() const
{
    CseObj vId;
    TCseObj EnValue = self->value;
    if (EnValue.len() <= 0 || Cse_type(vId = EnValue.sub(0)) != dtInt)
        throw LOG_CSE_ERR(CSE_VALUE_ERR,_T("the entity only created with S.e() can call exit()"));
    if (vId->iFlag != 0) return;  // already exited

    TInt EntityCount = ((TCseObj*)&SuperEntities)->len();
    TInt id = vId->iValue;
    if (id >= 0 && id < EntityCount)
    {
        // step 1: notify exiting
        trigger(constRemove);

        // step 2: unbind all current entity events
        TEntryArray& dArray = ((TCseObj*)&SuperEvents)->dArray();
        PEntryPoint pEntry = NULL;
        TCseObj dHook, CurrId = TIntObj(id);
        while (dArray.enumItem(pEntry,NULL,&dHook))
            dHook.set(CurrId,dummy);
    }

    // step 3: toggle 'exit' flag and set 'undefined' to SuperEntities
    vId->iFlag = 1;
    ((TCseObj*)&SuperEntities)->sub(id) = *CseSuper_UnknownObj;
    if (NULL != CseSuper_AfterExit)
        CseSuper_AfterExit(EnValue);
    else EnValue.bArray().truncate(1);
}

_TEntity _TEntity::bind(const TCseObj& EventName, const _TEntity& fn) const
{
    ASSERT_TRUE(Cse_OptionOn(fn->Id_,16) && Cse_type(fn->Id_) == dtBuff);
    ASSERT_TRUE(Cse_type(fn->value) == dtInt || Cse_type(fn->value) == dtStrong);

    CseObj vId = self->value.sub(0);
    if (Cse_type(vId) != dtInt)
        throw LOG_CSE_ERR(CSE_VALUE_ERR,_T("the entity only created with S.e() can bind event"));
    if (vId->iFlag != 0) return self;  // already exited

    TCseObj EvId = EventName.toId();
    TCseObj dHook = ((TCseObj*)&SuperEvents)->dArray().trySet(EvId,CseEmptyDict);

    TInt EntityCount = ((TCseObj*)&SuperEntities)->len();
    TInt id = vId->iValue;
    if (id >= 0 && id < EntityCount)
    {
        TCseObj bEvList = dHook.dArray().trySet(vId,CseEmptyBuff);
        bEvList.append(fn);  // same function can add many times
    }

    return self;
}

_TEntity _TEntity::unbind(const TCseObj& EventName, const _TEntity& fn) const
{
    CseObj vId = self->value.sub(0);
    if (Cse_type(vId) != dtInt) return self;  // ignore unbind
    if (vId->iFlag != 0) return self;         // already exited

    TInt iTargFunc = 0;
    TBool clearEvent = false;
    if (CseSuper_unknown == fn->Id_)
        clearEvent = true;
    else
    {
        ASSERT_TRUE(Cse_OptionOn(fn->Id_,16) && Cse_type(fn->Id_) == dtBuff);
        TCseObj vTargFunc = fn->value;
        ASSERT_TRUE(Cse_type(vTargFunc) == dtInt || Cse_type(vTargFunc) == dtStrong);
        iTargFunc = vTargFunc->iFlag;
    }

    TCseObj EvId = EventName.toId();
    TCseObj dHook = ((TCseObj*)&SuperEvents)->get(EvId);
    if (Cse_type(dHook) != dtDict) return self;

    TInt EntityCount = ((TCseObj*)&SuperEntities)->len();
    TInt id = vId->iValue;
    if (id >= 0 && id < EntityCount)
    {
        if (clearEvent)
            dHook.set(vId,dummy);
        else
        {
            TCseObj bEvList = dHook.get(vId);
            if (Cse_type(bEvList) == dtBuff)
            {
                for (int ii = bEvList.len() - 1; ii >= 0; ii--)
                {
                    _TEntity vFunc = (CseObj)bEvList.sub(ii);
                    TCseObj vSourFunc = vFunc->value;
                    if (vSourFunc->iFlag == iTargFunc)
                        bEvList.remove(ii);
                }
            }
        }
    }

    return self;
}

_TEntity _TEntity::trigger(const TCseObj& EventName, const TCseObj& args) const
{
    CseObj vId = self->value.sub(0);
    if (Cse_type(vId) != dtInt) return self;   // ignore trigger
    if (vId->iFlag != 0) return self;          // already exited, ignore

    TCseObj EvId = EventName.toId();
    TCseObj dHook = ((TCseObj*)&SuperEvents)->get(EvId);
    if (Cse_type(dHook) != dtDict) return self;

    TInt EntityCount = ((TCseObj*)&SuperEntities)->len();
    TInt id = vId->iValue;
    if (id >= 0 && id < EntityCount)
    {
        TCseObj bEvList = dHook.get(vId);
        if (Cse_type(bEvList) == dtBuff)
        {
            void *pIter = NULL;
            _TEntity EventFunc;
            TObjArray& bArray = bEvList.bArray();
            while (bArray.enumItem(pIter,&EventFunc))
                EventFunc.apply(self,args);
        }
    }

    return self;
}

_TEntity _TEntity::each(const _TEntity& EachFunc, const TCseObj& args) const
{
    CseObj bType = self->Id_;
    ASSERT_TRUE(CSE_TYPE(bType) == dtBuff && Cse_OptionOn(bType,16) && CSE_ARRAY_LEN(bType->bValue) > 0);
    if (bType->bValue[0]->iValue != 1)
        throw LOG_CSE_ERR(CSE_SYNTAX_ERR,_T("invalid owner of entity.each()"));

    EachFunc.apply(self,args);
    return self;
}

TCseObj _TEntity::call(const TCseObj& bArgs) const
{
    int iLen = bArgs.len();
    if (iLen > 16)
        throw LOG_CSE_ERR(CSE_ARGS_ERR,_T("too many arguments"));

    TCseObj *p = (TCseObj*) bArgs.bArray().addr();
    switch (iLen)
    {
    case 0:  return self();
    case 1:  return self(p[0]);
    case 2:  return self(p[0],p[1]);
    case 3:  return self(p[0],p[1],p[2]);
    case 4:  return self(p[0],p[1],p[2],p[3]);
    case 5:  return self(p[0],p[1],p[2],p[3],p[4]);
    case 6:  return self(p[0],p[1],p[2],p[3],p[4],p[5]);
    case 7:  return self(p[0],p[1],p[2],p[3],p[4],p[5],p[6]);
    case 8:  return self(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
    case 9:  return self(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8]);
    case 10: return self(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],p[9]);
    case 11: return self(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],p[9],p[10]);
    case 12: return self(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],p[9],p[10],p[11]);
    case 13: return self(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],p[9],p[10],p[11],p[12]);
    case 14: return self(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],p[9],p[10],p[11],p[12],p[13]);
    case 15: return self(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],p[9],p[10],p[11],p[12],p[13],p[14]);
    case 16: return self(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);
    }

    ASSERT_TRUE(false);  // can not reach here
    return dummy;
}

TCseObj _TEntity::apply(const TCseObj& This, const TCseObj& bArgs) const
{
    int iLen = bArgs.len();
    if (iLen > 15)
        throw LOG_CSE_ERR(CSE_ARGS_ERR,_T("too many arguments"));

    TCseObj *p = (TCseObj*) bArgs.bArray().addr();
    switch (iLen)
    {
    case 0:  return self(This);
    case 1:  return self(This,p[0]);
    case 2:  return self(This,p[0],p[1]);
    case 3:  return self(This,p[0],p[1],p[2]);
    case 4:  return self(This,p[0],p[1],p[2],p[3]);
    case 5:  return self(This,p[0],p[1],p[2],p[3],p[4]);
    case 6:  return self(This,p[0],p[1],p[2],p[3],p[4],p[5]);
    case 7:  return self(This,p[0],p[1],p[2],p[3],p[4],p[5],p[6]);
    case 8:  return self(This,p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
    case 9:  return self(This,p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8]);
    case 10: return self(This,p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],p[9]);
    case 11: return self(This,p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],p[9],p[10]);
    case 12: return self(This,p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],p[9],p[10],p[11]);
    case 13: return self(This,p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],p[9],p[10],p[11],p[12]);
    case 14: return self(This,p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],p[9],p[10],p[11],p[12],p[13]);
    case 15: return self(This,p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],p[9],p[10],p[11],p[12],p[13],p[14]);
    }

    ASSERT_TRUE(false);  // can not reach here
    return dummy;
}

void _TEntity::IntInit(const TCseObj& value) const
{
    TMngInt v((CseObj)value);
    self->value = v;
}

void _TEntity::WintInit(const TCseObj& value) const
{
    TMngWint v((CseObj)value);
    self->value = v;
}

void _TEntity::FloatInit(const TCseObj& value) const
{
    TMngFloat v((CseObj)value);
    self->value = v;
}

void _TEntity::StrInit(const TCseObj& value) const
{
    TMngStr v((CseObj)value);
    self->value = v;
}

void _TEntity::TierInit(const TCseObj& value) const
{
    TMngTier v((CseObj)value);
    self->value = v;
}

void _TEntity::BuffInit(const TCseObj& value) const
{
    TMngBuff v((CseObj)value);
    self->value = v;
}

void _TEntity::DictInit(const TCseObj& value) const
{
    TMngDict v((CseObj)value);
    self->value = v;
}

void _TEntity::ObjInit(const TCseObj& value) const
{
    self->value = value;
}

_TEntity CseSuper_EntityAttr( const _TEntity& obj, const TCseObj& attr, TBool checkErr, 
                              int BaseOff, TInt *pOffset, TInt *pIsEntity)
{
    ASSERT_TRUE(Cse_type(attr) == dtId);

    CseObj bInfo = obj->Id_;
    ASSERT_TRUE(CSE_TYPE(bInfo) == dtBuff && Cse_OptionOn(bInfo,16) && CSE_ARRAY_LEN(bInfo->bValue) > 0);
    TInt iFlag;
    if ( (int)CSE_ARRAY_LEN(bInfo->bValue) >= (3 + BaseOff) && 
         ((iFlag = bInfo->bValue[0]->iValue) == 1 || iFlag == 3) ) // UDT or Array
        ;  // OK
    else
        throw LOG_CSE_ERR(CSE_VALUE_ERR,TCharArray::format(_T("get attr (%s) error: entity is not UDT or array"),attr->sValue));

    if (iFlag == 3 && BaseOff == 0)
    {
        if (checkErr)
        {
            TCharArray sErr = _T("super object attribute error: ") + attr.beStr();
            throw LOG_CSE_ERR(CSE_ATTR_ERR,sErr);
        }
        else return _TEntity();
    }

    TCseObj bAttr = bInfo->bValue[1 + BaseOff];
    CseObj *pAttr = bAttr.bArray().addr();
    TUint CurrObj = (TUint)(CseObj)attr;

    int iLow  = 0;
    int iHigh = bAttr.len() - 1;
    int index = -1;

    while (iLow <= iHigh)
    {
        int iHalf = (iLow + iHigh) >> 1;  // div 2
        TUint NowObj = (TUint)pAttr[iHalf];

        if (NowObj == CurrObj)
        {
            index = iHalf;
            break;
        }
        else if (NowObj < CurrObj)
            iLow = iHalf + 1;
        else iHigh = iHalf - 1;
    }

    if (index == -1)
    {   // attr inexistent
        if (checkErr)
        {
            TCharArray sErr = TCharArray::format(_T("attribute (%s) of entity inexistent"),attr->sValue);
            throw LOG_CSE_ERR(CSE_ATTR_ERR,sErr);
        }
        else return _TEntity();
    }
    else
    {
        TCseObj bType = bInfo->bValue[2 + BaseOff];
        int offset = index * 2;
        ASSERT_TRUE(offset + 1 < bType.len());
        CseObj vSubType = bType.sub(offset+1);
        ASSERT_TRUE(dummy == vSubType || CSE_TYPE(vSubType) == dtWeak || CSE_TYPE(vSubType) == dtStrong);

        if ( dummy != vSubType && Cse_type(vSubType = vSubType->vValue) == dtBuff && 
             Cse_OptionOn(vSubType,16) && CSE_ARRAY_LEN(vSubType->bValue) >= 1 )
        {
            CseObj SubUdtFlag = vSubType->bValue[0];
            _TEntity vRet;

            TBool succ = true;
            if (SubUdtFlag->iValue != 1 && SubUdtFlag->iValue != 2 && SubUdtFlag->iValue != 3)
                succ = false;
            else if (BaseOff != 0)
            {   // current find from prototype area
                CseObj vAddr = bType.sub(offset);
                if (CSE_TYPE(vAddr) == dtStrong)
                {
                    vRet->value = vAddr->vValue;
                    if (pOffset != NULL) *pOffset = (TInt)vAddr;
                }
                else
                {
                    ASSERT_TRUE(CSE_TYPE(vAddr) == dtInt);
                    vRet->value = *(CseObj*)vAddr->vValue;
                    if (pOffset != NULL) *pOffset = vAddr->iValue;
                }
            }
            else
            {   // normal UDT member
                TCseObj ObjData = obj->value;

                TInt iSubIndex = bType.sub(offset)->iValue;
                if (Cse_type(ObjData) != dtBuff || iSubIndex >= ObjData.len())
                    succ = false;
                else
                {
                    vRet->value = ObjData.sub(iSubIndex);
                    if (pOffset != NULL) *pOffset = iSubIndex;
                }
            }

            if (! succ)
            {
                TCharArray sErr = _T("super object attribute error: ") + attr.beStr();
                throw LOG_CSE_ERR(CSE_ATTR_ERR,sErr);
            }
            else vRet->Id_ = vSubType;

            if (SuperEntityType == vSubType)  // member type is: Entity
            {
                if (pIsEntity != NULL)
                    *pIsEntity = 1;
                return _TEntity(vRet->value);
            }
            else return vRet;
        }

        if (checkErr)
        {
            TCharArray sErr = TCharArray::format(_T("attribute (%s) information lost"),attr->sValue);
            throw LOG_CSE_ERR(CSE_SYSTEM_ERR,sErr);
        }
        else return _TEntity();
    }
}

TEntityType::TEntityType(const TMngStr& name, const TMngInt& size) : TCseObj(CseEmptyBuff)
{
    append(CseSuper_NewUdt(TCseObj::format(CSE_ID,name.addr()),(TInt)size));
    append(dummy);
}

TEntityType::TEntityType(const _TEntity& obj) : TCseObj(CseEmptyBuff)
{
    append(obj.sub(0));
    append(dummy);
}

TEntityType::TEntityType(const TEntityType& obj): TCseObj(obj.m_data)
{
    ASSERT_TRUE(CSE_TYPE(m_data) == dtBuff && Cse_len(m_data) == 2 && Cse_OptionOn(m_data->bValue[0],16));
}

TEntityType TEntityType::addMemb(const TMngStr& attr, const TMngStr& type, const TMngInt& offset) const
{
    CseSuper_AddMemb(self->Id_,attr.addr(),type.addr(),(TInt)offset);
    return self;
}

TEntityType TEntityType::addFunc(const TMngStr& attr, const TMngInt& offset, const TMngStr& sArgs, const TCseObj& bDefault) const
{
    CseSuper_AddFunc(self->Id_,attr.addr(),(TInt)offset,sArgs.addr(),bDefault);
    return self;
}

TEntityType TEntityType::addProt(const TMngStr& attr, const TMngInt& addr, const TMngStr& sArgs, const TMngStr& type, const TCseObj& bDefault, TBool ClsStatic) const
{
    CseSuper_AddProt(self->Id_,attr.addr(),(TInt)addr,sArgs.addr(),type.addr(),bDefault,ClsStatic);
    return self;
}

TCseException NewArrayTypeErr()
{
    return LOG_CSE_ERR(CSE_VALUE_ERR,_T("entity array type error"));
}

_TArray::_TArray(const _TArray& obj): TCseObj(obj.m_data)
{   // copy construct
    ASSERT_TRUE(CSE_TYPE(m_data) == dtBuff && Cse_len(m_data) == 2);

    CseObj bType = m_data->bValue[0];
    ASSERT_TRUE(Cse_OptionOn(bType,16) && CSE_TYPE(bType) == dtBuff && Cse_len(bType) > 0);
    if (bType->bValue[0]->iValue != 3)
        throw NewArrayTypeErr();
}

TBool SuperArrMatched(const TCseObj& bType1, const TCseObj& bType2)
{   // bType1 and bType2 is array
    if (bType1.len() >= 3 && bType2.len() >= 3)
    {
        CseObj vSub1 = bType1->bValue[2];
        int tp1 = CSE_TYPE(vSub1);
        CseObj vSub2 = bType2->bValue[2];
        int tp2 = CSE_TYPE(vSub2);
        if ((tp1 == dtWeak || tp1 == dtStrong) && (tp2 == dtWeak || tp2 == dtStrong))
        {
            TCseObj SubType1 = vSub1->vValue;
            TCseObj SubType2 = vSub2->vValue;
            if ( Cse_type(SubType1) == dtBuff && SubType1.len() > 0 &&
                 Cse_type(SubType2) == dtBuff && SubType2.len() > 0 )
            {
                if (SubType1.sub(0)->iValue == 2 && SubType2.sub(0)->iValue == 2)
                    return true;  // take super function as matched
                else if (SubType1.compare(SubType2) == 0)
                    return true;
            }
        }
    }
    return false;
}

TCseObj ArrayItemContent(CseObj RegistedType, const TCseObj& value)
{
    if (value.type() == dtBuff && value.len() == 2)
    {
        TCseObj ValueType = value.sub(0);
        if (ValueType.type() == dtBuff && ValueType.optionOn(16) && ValueType.len() >= 1)
        {
            int iFlag = RegistedType->bValue[0]->iValue;
            if (iFlag == ValueType.sub(0)->iValue)
            {
                if (iFlag == 1)
                {
                    if (ValueType.compare(RegistedType) == 0)
                        return value.sub(1);
                }
                else if (iFlag == 2)
                    return value.sub(1); // take super function as matched
                else if (iFlag == 3)
                {
                    if (SuperArrMatched(RegistedType,ValueType))
                        return value.sub(1);
                }
            }
            throw LOG_CSE_ERR(CSE_VALUE_ERR,_T("type of array mismatch"));
        }
        // else, return value;
    }

    return value;
}

_TEntity _TArray::operator()(const TMngInt& index, const TCseObj& value) const
{
    CseObj SelfType = self->Id_;
    ASSERT_TRUE( CSE_TYPE(SelfType) == dtBuff && Cse_OptionOn(SelfType,16) && 
                 CSE_ARRAY_LEN(SelfType) >= 1 && SelfType->bValue[0]->iValue == 3 );
    TCseObj RegistedType = SelfType->bValue[2]->vValue;
    TCseObj v = self->bItems;

    TCseObj vTarg;
    if (dummy != value)
    {   // set sub-value
        vTarg = ArrayItemContent(RegistedType,value);
        v.sub(index) = vTarg;
    }
    else vTarg = v.sub(index);

    // return sub-value
    _TEntity vRet;
    vRet->Id_   = RegistedType;
    vRet->value = vTarg;
    return vRet;
}

TIntObj _TArray::push(const TCseObj& value, const TCseObj& args) const
{
    CseObj SelfType = self->Id_;
    ASSERT_TRUE( CSE_TYPE(SelfType) == dtBuff && Cse_OptionOn(SelfType,16) && 
                 CSE_ARRAY_LEN(SelfType) >= 1 && SelfType->bValue[0]->iValue == 3 );
    TCseObj RegistedType = SelfType->bValue[2]->vValue;

    int iRet = 0;
    TObjArray& bList = self->bItems.bArray();
    TCseObj vTarg = ArrayItemContent(RegistedType,value);
    bList.add(vTarg,&iRet);

    TObjArray& bArgs = args.bArray();
    int iLen = bArgs.len();
    for (int i = 0; i < iLen; i++)
    {
        vTarg = ArrayItemContent(RegistedType,bArgs.sub(i));
        bList.add(vTarg,&iRet);
    }

    return iRet + 1;  // same to len(), but suitable for multi-thread
}

_TEntity _TArray::pop(const TMngInt& index) const
{
    CseObj SelfType = self->Id_;
    ASSERT_TRUE( CSE_TYPE(SelfType) == dtBuff && Cse_OptionOn(SelfType,16) && 
                 CSE_ARRAY_LEN(SelfType) >= 1 && SelfType->bValue[0]->iValue == 3 );
    TCseObj RegistedType = SelfType->bValue[2]->vValue;

    TCseObj vTarg = self->bItems.pop(index);

    _TEntity vRet;
    vRet->Id_ = RegistedType;
    vRet->value = vTarg;
    return vRet;
}

_TEntity _TArray::shift() const
{
    CseObj SelfType = self->Id_;
    ASSERT_TRUE( CSE_TYPE(SelfType) == dtBuff && Cse_OptionOn(SelfType,16) && 
                 CSE_ARRAY_LEN(SelfType) >= 1 && SelfType->bValue[0]->iValue == 3 );
    TCseObj RegistedType = SelfType->bValue[2]->vValue;

    TCseObj vTarg = self->bItems.pop(0);

    _TEntity vRet;
    vRet->Id_ = RegistedType;
    vRet->value = vTarg;
    return vRet;
}

TIntObj _TArray::unshift(const TCseObj& value, const TCseObj& args) const
{
    CseObj SelfType = self->Id_;
    ASSERT_TRUE( CSE_TYPE(SelfType) == dtBuff && Cse_OptionOn(SelfType,16) && 
                 CSE_ARRAY_LEN(SelfType) >= 1 && SelfType->bValue[0]->iValue == 3 );
    TCseObj RegistedType = SelfType->bValue[2]->vValue;

    TObjArray& bList = self->bItems.bArray();
    TCseObj vTarg = ArrayItemContent(RegistedType,value);
    int iRet = bList.insert_(0,vTarg);

    TObjArray& bArgs = args.bArray();
    for (int i = bArgs.len() - 1; i >= 0; i--)
    {
        vTarg = ArrayItemContent(RegistedType,bArgs.sub(i));
        iRet = bList.insert_(1,vTarg);
    }

    return iRet;
}

_TEntity _TArray::sliceOf(const TMngInt& index, const TMngInt& iLen) const
{
    _TEntity ret;
    ret->Id_ = self->Id_;
    ret->value = self->bItems.slice(index,iLen);

    return ret;
}

TCharArray _TArray::desc(const TMngStr& separator) const
{
    void *pIter = NULL;
    TObjArray& bArray = self->bItems.bArray();

    TCharArray ret(_T("["));
    TBool isFirst = true;
    TCseObj item;
    while (bArray.enumItem(pIter,&item))
    {
        if (isFirst)
            ret += item.str();
        else ret += separator + item.str();
        isFirst = false;
    }
    ret += _T(']');

    return TCharArray(CUT_FROM,ret);
}

_TEntity _TArray::concat(const _TEntity& that) const
{
    TCseObj bType = self->Id_;
    if (SuperArrMatched(bType,that->Id_))
    {   // 
        TCseObj bRet(CseEmptyBuff);
        bRet.join(self->bItems);
        bRet.join(that->value);

        _TEntity en;
        en->Id_ = bType;
        en->value = bRet;
        return en;
    }
    else throw LOG_CSE_ERR(CSE_TYPE_ERR,_T("super array type mismatch"));
}

_TEntity _TArray::reverse() const
{
    TObjArray& bItems = self->bItems.bArray();
    TObjArray bTmp;
    bTmp.join(bItems);
    bItems.truncate(0);

    void *pIter = NULL;
    TCseObj value;
    while (bTmp.enumItem(pIter,&value))
        bItems.insert(0,value);

    return (CseObj)*this;
}

_TEntity _TArray::splice(const TMngInt& iStart,const TMngInt& iDelNum,const TCseObj& args) const
{
    CseObj SelfType = self->Id_;
    ASSERT_TRUE( CSE_TYPE(SelfType) == dtBuff && Cse_OptionOn(SelfType,16) && 
                 CSE_ARRAY_LEN(SelfType) >= 1 && SelfType->bValue[0]->iValue == 3 );
    TCseObj RegistedType = SelfType->bValue[2]->vValue;

    TCseObj bItem = self->bItems;
    int iBegin = iStart;
    int iDel = iDelNum;
    if (iDel < 0) iDel = bItem.len();
    
    TObjArray bTmp = bItem.bArray().slice(iBegin,iDel);
    bItem.remove(iBegin,bTmp.len());

    TCseObj vItem;
    void *pIter = NULL;
    TObjArray& bValue = args.bArray();
    while (bValue.enumItem(pIter,&vItem))
    {
        TCseObj vTarg = ArrayItemContent(RegistedType,vItem);
        bItem.insert(iBegin,vTarg);
        iBegin++;
    }

    _TEntity en;
    en->Id_ = self->Id_;
    en->value = TCseObj(CUT_FROM,bTmp);
    return en;
}

_TLinker::_TLinker(): TCseObj(TCseObj::format(CSE_WEAK,0))
{
}

_TLinker::_TLinker(const _TLinker& linker): TCseObj(linker.m_data)
{
    ASSERT_TRUE(Cse_type(m_data) == dtWeak);
}

_TLinker& _TLinker::operator=(const _TLinker& obj)
{
    ASSERT_TRUE(Cse_type(obj.m_data) == dtWeak);
    *(TCseObj*)this = obj.m_data;
    return *this;
}

_TEntity _TLinker::operator()(const TMngInt& root) const
{
    CseObj bType_ = m_data->vValue;
    CHECK_MSG(bType_ != NULL,_T("SLinker not initialized"));

    TUint32 iFlag = (TUint32) m_data->iFlag;
    int eid = (int) (iFlag & 0xFFFF);
    _TEntity vRoot = SuperEntities->bValue[eid];
    if (root != 0)
        return vRoot;

    int offset = (int) (iFlag >> 16);
    CHECK_MSG(offset > 0 && eid >= 0 && (TUint)eid < CSE_ARRAY_LEN(SuperEntities->bValue),_T("SLinker() out of range"));

    _TEntity vRet;
    vRet->Id_ = bType_;
    vRet->value = vRoot->value.sub(offset);
    return vRet;
}

void DoSuperSelect(const _TSelector& me, const TCharArray& selector, TInt from = 0, TInt num = -1, TInt to = -1)
{
    TObjArray& bSuperList = ((TCseObj*)&SuperEntities)->bArray();
    int iSuperLen = bSuperList.len();
    if (from < 0) from += iSuperLen;
    if (from < 0) from = 0;
    if (num < 0) num = iSuperLen;
    if (to < 0) to += iSuperLen;
    if (to >= iSuperLen) to = iSuperLen - 1;

    int iCount = 0;
    if (selector == _T("*"))
    {   // select all
        TObjArray AllEntity;
        for (int ii = from; (ii <= to) && (iCount < num); ii++)
        {
            TCseObj OneItem = bSuperList.sub(ii); 
            ASSERT_TRUE(Cse_type(OneItem) == dtBuff && OneItem.len() > 0);

            if (CseSuper_unknown != OneItem.sub(0))
            {
                AllEntity.append(OneItem);
                iCount++;
            }
        }

        me->bItems.bArray().join(AllEntity);
        return;
    }

    TObjArray bSelector;
    TBool isAnd = false;

    TObjArray bList = selector.split(_T(","));
    int iLen = bList.len();
    if (iLen == 0)
    {   // no ','
        bList = selector.split();
        iLen = bList.len();
        if (iLen == 0)
        {   // selector is only one word, isAnd = false;
            TCharArray sItem = selector;
            sItem.trim();
            if (sItem.len())
                bSelector.append(TCseObj::format(CSE_ID,sItem.addr()));
        }
        else
        {
            isAnd = true;
            for (int i = 0; i < iLen; i++)
            {
                TCharArray& sItem = bList.sub(i).sArray();
                bSelector.append(TCseObj::format(CSE_ID,sItem.addr()));
            }
        }
    }
    else // isAnd = false;
    {
        for (int i = 0; i < iLen; i++)
        {
            TCharArray& sItem = bList.sub(i).sArray();
            sItem.trim();
            if (sItem.find(_T(" ")) >= 0)
                throw LOG_CSE_ERR(CSE_ARGS_ERR,_T("selector format (AND/OR) error"));

            if (sItem.len())
                bSelector.append(TCseObj::format(CSE_ID,sItem.addr()));
        }
    }
    int iLen2 = bSelector.len();
    if (iLen2 == 0) return;

    TObjArray EntitySet;
    for (int index = from; (index <= to) && (iCount < num); index++)
    {
        TCseObj OneItem = bSuperList.sub(index);
        ASSERT_TRUE(Cse_type(OneItem) == dtBuff && OneItem.len() > 0);

        CseObj ItemType = OneItem.sub(0);
        if (CseSuper_unknown == ItemType)
            continue;

        ASSERT_TRUE(Cse_type(ItemType) == dtBuff && CSE_ARRAY_LEN(ItemType->bValue) >= 2);
        TObjArray &AttrList = (TObjArray&)ItemType->bValue[1]->bValue;
        CseObj *pAttr = AttrList.addr();

        int iMatch = 0;
        for (int index2 = 0; index2 < iLen2; index2++)
        {
            TUint CurrObj = (TUint)(CseObj)bSelector.sub(index2);

            int iLow  = 0;
            int iHigh = AttrList.len() - 1;
            int iLast = -1;

            while (iLow <= iHigh)
            {
                int iHalf = (iLow + iHigh) >> 1;  // div 2
                TUint NowObj = (TUint)pAttr[iHalf];

                if (NowObj == CurrObj)
                {
                    iLast = iHalf;
                    break;
                }
                else if (NowObj < CurrObj)
                    iLow = iHalf + 1;
                else iHigh = iHalf - 1;
            }

            if (iLast >= 0)
            {   // has found
                iMatch++;
                if (! isAnd) break;
            }
            else
            {
                if (isAnd) break;
            }
        }

        if ((isAnd && iMatch == iLen2) || (!isAnd && iMatch > 0) )
        {
            EntitySet.append(OneItem);
            iCount++;
        }
    }

    me->bItems.bArray().join(EntitySet);  // copy result
}

_TSelector::_TSelector(): TCseObj(CseEmptyBuff)
{
    append(SuperSelectorType);
    append(CseEmptyBuff);
}

_TSelector::_TSelector(const TMngInt& index): TCseObj(CseEmptyBuff)
{
    append(SuperSelectorType);
    append(CseEmptyBuff);

    // try select one entity
    TInt id = index;
    if (id >= 0 && id < ((TCseObj*)&SuperEntities)->len())
        self->bItems.append(SuperEntities->bValue[id]);
    // else, out of range, just ignore
}

_TSelector::_TSelector(const TXchar *selector, TInt from, TInt num, TInt to): TCseObj(CseEmptyBuff)
{
    append(SuperSelectorType);
    append(CseEmptyBuff);

    // start selecting
    DoSuperSelect(self,selector,from,num,to);
}

_TEntity _TSelector::operator()(const TMngInt& i) const
{
    return (CseObj)self->bItems.sub(i);
}

void _TSelector::init(const TCseObj& SQL, const TMngInt& from, const TMngInt& num, const TMngInt& to) const
{
    self->Id_ = SuperSelectorType;
    self->bItems = CseEmptyBuff;

    if (dummy != SQL)
        reset(SQL,from,num,to);
}

_TSelector _TSelector::join(const _TSelector& other) const
{
    CseObj other_ = other.m_data;
    CHECK_MSG( Cse_type(other_) == dtBuff && CSE_ARRAY_LEN(other_->bValue) == 2 &&
               SuperSelectorType == other_->bValue[0], _T("invalid selector: S.join(selector)") );

    self->bItems.join(other->bItems);
    return self;
}

_TSelector _TSelector::exit() const
{   // step 1: notify exiting
    trigger(constRemove);

    // step 2: unbind current selected entities's event
    TObjArray& bList = self->bItems.bArray();
    TEntryArray& dArray = ((TCseObj*)&SuperEvents)->dArray();
    PEntryPoint pEntry = NULL;
    TCseObj dHook;
    while (dArray.enumItem(pEntry,NULL,&dHook))
    {
        _TEntity oneEntity;
        void *pOneIter = NULL;
        while (bList.enumItem(pOneIter,&oneEntity))
            dHook.set(oneEntity->value.sub(0),dummy);
    }

    // step 3: toggle 'exit' flag and set 'undefined' to SuperEntities
    _TEntity en;
    void *pIter = NULL;
    while (bList.enumItem(pIter,&en))
    {
        TCseObj EnValue = en->value;
        CseObj vId = EnValue.sub(0);
        vId->iFlag = 1;

        // set undefined to global enitity table
        TInt id = vId->iValue;
        ASSERT_TRUE(id >= 0 && id < ((TCseObj*)&SuperEntities)->len());
        ((TCseObj*)&SuperEntities)->sub(id) = *CseSuper_UnknownObj;

        if (NULL != CseSuper_AfterExit)
            CseSuper_AfterExit(EnValue);
        else EnValue.bArray().truncate(1);
    }

    // step 4: clear self select-set
    bList.clear();

    return self;
}

_TSelector _TSelector::reset(const TCseObj& SQL, const TMngInt& from, const TMngInt& num, const TMngInt& to) const
{
    self->bItems.clear();  // clean all history items

    int tp = Cse_type(SQL);
    if (tp == dtInt)
    {   // try select one entity
        int index = SQL->iValue;

        TCseObj entities(SuperEntities);
        if (index >= 0 && index < entities.len())
            self->bItems.append(entities.sub(index));
        else
        {   // out of range
            throw LOG_CSE_ERR(CSE_RANGE_ERR,_T("Selector.reset(n) out of range"));
        }
    }
    else if (tp == dtStr)
    {   // perform selecting
        DoSuperSelect(self,SQL.sArray(),from,num,to);
    }
    else throw LOG_CSE_ERR(CSE_ARGS_ERR,_T("argument of Selector.reset(SQL) error"));

    return self;
}

_TSelector _TSelector::filter(const _TEntity& FilterFunc, const TCseObj& args) const
{   // FilterFunc,args1,arg2...
    // S(--).filter(super(me,arg1,...) as i: ... end, arg1,arg2...);
    TObjArray& bList = self->bItems.bArray();

    int i = 0;
    while (i < bList.len())
    {
        _TEntity en = (CseObj)bList.sub(i);
        if (en->value.sub(0)->iFlag != 0)
        {   // entity already exit
            bList.remove(i);
            continue;
        }

        TCseObj ret = FilterFunc.apply(en,args);
        if (ret->iValue == 0)
            bList.remove(i);     // if filter condition failed, remove the item
        else i++;
    }

    return self;
}

_TSelector _TSelector::each(const _TEntity& EachFunc, const TCseObj& args) const
{   // S(--).each(super(me,arg1,...): ... end, arg1,arg2...);
    TObjArray& bList = self->bItems.bArray();

    int iLen = bList.len();
    for (int i = 0; i < iLen; i++)
    {
        _TEntity en = (CseObj)bList.sub(i);
        if (en->value.sub(0)->iFlag != 0) continue;  // entity already exit
        EachFunc.apply(en,args);   // run each-func
    }

    return self;
}

_TSelector _TSelector::bind(const TCseObj& EventName, const _TEntity& fn) const
{
    ASSERT_TRUE(Cse_OptionOn(fn->Id_,16) && Cse_type(fn->Id_) == dtBuff);
    ASSERT_TRUE(Cse_type(fn->value) == dtInt || Cse_type(fn->value) == dtStrong);

    TCseObj EvId = EventName.toId();
    TCseObj dHook = ((TCseObj*)&SuperEvents)->dArray().trySet(EvId,CseEmptyDict);

    TInt EntityCount = ((TCseObj*)&SuperEntities)->len();
    TObjArray& bList = self->bItems.bArray();
    int iLen = bList.len();
    for (int i = 0; i < iLen; i++)
    {
        _TEntity en = (CseObj)bList.sub(i);
        TCseObj vId = en->value.sub(0);
        if (vId->iFlag != 0) continue;  // entity already exit

        TInt id = vId->iValue;
        if (id >= 0 && id < EntityCount)
        {
            TCseObj bEvList = dHook.dArray().trySet(vId,CseEmptyBuff);
            bEvList.append(fn);  // same function can add many times
        }
    }

    return self;
}

_TSelector _TSelector::unbind(const TCseObj& EventName, const _TEntity& fn) const
{
    TInt iTargFunc = 0;
    TBool clearEvent = false;
    if (CseSuper_unknown == fn->Id_)
        clearEvent = true;
    else
    {
        ASSERT_TRUE(Cse_OptionOn(fn->Id_,16) && Cse_type(fn->Id_) == dtBuff);
        TCseObj vTargFunc = fn->value;
        ASSERT_TRUE(Cse_type(vTargFunc) == dtInt || Cse_type(vTargFunc) == dtStrong);
        iTargFunc = vTargFunc->iFlag;
    }

    TCseObj EvId = EventName.toId();
    TCseObj dHook = ((TCseObj*)&SuperEvents)->get(EvId);
    if (Cse_type(dHook) != dtDict) return self;

    TInt EntityCount = ((TCseObj*)&SuperEntities)->len();
    TObjArray& bList = self->bItems.bArray();
    int iLen = bList.len();
    for (int i = 0; i < iLen; i++)
    {
        _TEntity en = (CseObj)bList.sub(i);
        TCseObj vId = en->value.sub(0);
        TInt id = vId->iValue;
        if (id >= 0 && id < EntityCount)
        {
            if (clearEvent)
                dHook.set(vId,dummy);
            else
            {
                TCseObj bEvList = dHook.get(vId);
                if (Cse_type(bEvList) == dtBuff)
                {
                    for (int ii = bEvList.len() - 1; ii >= 0; ii--)
                    {
                        _TEntity vFunc = (CseObj)bEvList.sub(ii);
                        TCseObj vSourFunc = vFunc->value;
                        if (vSourFunc->iFlag == iTargFunc)
                            bEvList.remove(ii);
                    }
                }
            }
        }
    }

    return self;
}

_TSelector _TSelector::trigger(const TCseObj& EventName, const TCseObj& args) const
{
    TCseObj EvId = EventName.toId();
    TCseObj dHook = ((TCseObj*)&SuperEvents)->get(EvId);
    if (Cse_type(dHook) != dtDict) return self;

    TInt EntityCount = ((TCseObj*)&SuperEntities)->len();
    TObjArray& bList = self->bItems.bArray();
    int iLen = bList.len();

    if (iLen < EntityCount)
    {   // not select all, enum item by self select-set
        for (int i = 0; i < iLen; i++)
        {
            _TEntity en = (CseObj)bList.sub(i);
            TCseObj vId = en->value.sub(0);
            if (vId->iFlag != 0) continue;  // entity already exit

            TInt id = vId->iValue;
            if (id >= 0 && id < EntityCount)
            {
                TCseObj bEvList = dHook.get(vId);
                if (Cse_type(bEvList) == dtBuff)
                {
                    void *pIter = NULL;
                    _TEntity EventFunc;
                    TObjArray& bArray = bEvList.bArray();
                    while (bArray.enumItem(pIter,&EventFunc))
                        EventFunc.apply(en,args);
                }
            }
        }
    }
    else  // iLen >= EntityCount, it should be global event
    {   // current is select all, enum item by SuperEvents[EventName]
        PEntryPoint pEntry = NULL;
        TCseObj key,bEvList;
        TEntryArray& dArray = dHook.dArray();
        while (dArray.enumItem(pEntry,&key,&bEvList))
        {
            ASSERT_TRUE(Cse_type(bEvList) == dtBuff);

            TInt id = key->iValue;
            if (id >= 0 && id < EntityCount)
            {
                _TEntity en = SuperEntities->bValue[id];
                if (en->value.sub(0)->iFlag != 0) continue;  // entity already exit

                void *pIter = NULL;
                _TEntity EventFunc;
                TObjArray& bArray = bEvList.bArray();
                while (bArray.enumItem(pIter,&EventFunc))
                    EventFunc.apply(en,args);
            }
        }
    }

    return self;
}

_TEntity CreateOneEntity(const TCseObj& bType)
{
    ASSERT_TRUE(Cse_OptionOn(bType,16) && Cse_type(bType) == dtBuff && bType.len() > 0);
    CseObj vFlag = bType.sub(0);
    if ( vFlag->iValue != 2 && vFlag->iValue != 3 && (vFlag->iValue != 1 || vFlag->iFlag < 0) ) 
        throw LOG_CSE_ERR(CSE_SYSTEM_ERR,_T("entity type format error"));

    _TEntity entity;
    entity->Id_ = bType;
    if (vFlag->iValue == 2)
    {   // function
        entity->value = TIntObj(0xCCCCCCCC);
    }
    else
    {   // UDT or Array
        TCseObj bRet(CseEmptyBuff);
        if (vFlag->iFlag > 0)
        {
            bRet.bArray().resize(vFlag->iFlag);

            TCseObj bInitValue,bAttr;
            int iInitLen;
            if (bType.len() >= 7 && (iInitLen = (bInitValue = bType.sub(6)).len()) == (bAttr = bType.sub(1)).len())
            {
                TCseObj bAttrInfo = bType.sub(2);
                TCseObj *pObj = (TCseObj *)bRet->bValue;
                for (int i = 0; i < iInitLen; i++)
                {
                    int iOff = i << 1;
                    bRet.sub(bAttrInfo.sub(iOff)->iValue) = CopyUdtInitValue(bInitValue.sub(i));
                }
            }
        }

        entity->value = bRet;

        _TEntity vFunc = CseSuper_EntityAttr(entity,constInit,false,2);  // only find from prototype
        CseObj bSubType = vFunc->Id_;
        if (CseSuper_unknown != bSubType)   // has 'init' function
        {
            ASSERT_TRUE(Cse_OptionOn(bSubType,16) && CSE_TYPE(bSubType) == dtBuff && Cse_len(bSubType) >= 1);
            if (bSubType->bValue[0]->iValue == 2)
            {
                if (CSE_ARRAY_LEN(bSubType->bValue) >= 4 && SuperEntityType == bSubType->bValue[3]->vValue)
                    vFunc(entity);         // call entity.init()
                else vFunc(bRet);
            }
        }
    }
    return entity;
}

static TCseObj CreateArrayType(const TCseObj& AType)
{   // AType is weak(Type) / strong(Type)
    TCseObj ret(CseEmptyBuff);
    Cse_SetOption(ret,16);
    ret.append(TIntObj(3));  // data size is 0
    ret.append(TIntObj(0));
    ret.append(AType);
    ret.join(SuperArrayType,3);

    return ret;
}

extern void ScanArguments(TCseObj& RetType, TObjArray& bArgs, const TCharArray& ArgDesc);

namespace __S
{

_TEntity E(const TMngInt& eid)
{
    TInt id = eid;
    if (id >= 0 && id < ((TCseObj*)&SuperEntities)->len())
    {
        _TEntity en = SuperEntities->bValue[id];
        if (en == CseSuper_unknown)
            throw LOG_CSE_ERR(CSE_VALUE_ERR,_T("entity has destoried: ") + eid.str());
        else return en;
    }
    else throw LOG_CSE_ERR(CSE_VALUE_ERR,_T("eid out of range: ") + eid.str());
}

// simulate topmost level entity type
// -----------------------------------------
// class _TopLevelEntity: public _TMngUdt
// {   MNG_SUPER_BEGIN(_TopLevelEntity,_TMngUdt)
//       TMngInt      Id_;
//       component1   #noname;
//       component2   #noname;
//       ....
//     MNG_SUPER_END(_TopLevelEntity,_TMngUdt)
// public:
//     TIntObj eid() const;
//     TIntObj has(const TCseObj& Attr) const;
// };
//
_TEntity e(const TMngStr& selector, const TMngInt& NoCache)
{   // create new entity within CSE-SUPER

    TObjArray bSelector;
    TObjArray bIsArray;
    TObjArray bList = selector.split(_T(","));
    int iLen = bList.len();
    if (iLen == 0)
    {
        bList.append(selector.sArray());
        iLen = 1;
    }

    for (int i = 0; i < iLen; i++)
    {
        TCharArray& sItem = bList.sub(i).sArray();
        sItem.trim();
        if (sItem.isEmpty()) continue;

        TObjArray bList2 = sItem.split();
        int WordNum = bList2.len();
        if (WordNum == 0)
        {
            if (sItem[-1] == _T('*') && sItem.len() >= 2)
            {   // C1*
                sItem.remove(-1);
                if (sItem.len())
                {
                    TCseObj name = TCseObj::format(CSE_ID,sItem.addr());
                    bSelector.append(name);
                    bIsArray.append(TIntObj(1));
                }
                // else, ignore "*"
            }
            else
            {   // C1
                TCseObj name = TCseObj::format(CSE_ID,sItem.addr());
                bSelector.append(name);
                bIsArray.append(TIntObj(0));
            }
        }
        else
        {
            TInt isArray = 0;
            TCseObj name;
            if (WordNum == 2 && bList2.sub(1).sArray() == _T("*"))
            {   // C1 *
                isArray = 1;
                name = bList2.sub(0);
            }
            else throw LOG_CSE_ERR(CSE_ARGS_ERR,_T("invalid component: ") + sItem);
            
            name = name.toId();
            bSelector.append(name);
            bIsArray.append(TIntObj(isArray));
        }
    }

    int iLen2 = bSelector.len();
    if (iLen2 == 0)
        throw LOG_CSE_ERR(CSE_ARGS_ERR,_T("no component selected"));
    TCseObj *pComponent = (TCseObj*) &SuperComponents;

    // setup component information
    TObjArray bComponents;
    TObjArray bCompTypes,bCompTpInfo;
    for (int index = 0; index < iLen2; index++)
    {   // first, get component type info
        TCseObj CompName = bSelector.sub(index);
        TBool   isArrayType = bIsArray.sub(index)->iValue != 0;
        TCseObj item = pComponent->get(CompName);
        if (dummy == item)
        {
            TCharArray sErr = _T("can not find component: ") + CompName.beStr();
            throw LOG_CSE_ERR(CSE_VALUE_ERR,sErr);
        }
        ASSERT_TRUE(Cse_type(item) == dtBuff && Cse_OptionOn(item,16) && item.len() >= 1);
        bComponents.append(item);

        // then, setup component type list
        int inserted = 0;
        TUint vName = (TUint)(CseObj)CompName;
        int i1 = bCompTypes.len();
        CseObj *pObj = bCompTypes.addr() + (i1 - 1);  // point to last one

        for (; i1 >= 1; i1--, pObj--)
        {
            if (vName >= *(TUint*)pObj)
            {
                inserted = i1;
                break;
            }
        }

        bCompTypes.insert(inserted,CompName);
        inserted = inserted << 1;  // * 2
        if (isArrayType)
        {   // item has hold by global table
            TCseObj bArrType = CreateArrayType(TCseObj::format(CSE_WEAK,(CseObj)item));
            bCompTpInfo.insert(inserted,TCseObj::format(CSE_STRONG,(CseObj)bArrType));
        }
        else bCompTpInfo.insert(inserted,TCseObj::format(CSE_WEAK,(CseObj)item));
        bCompTpInfo.insert(inserted,TIntObj(index + 1));  // data offset
    }
    
    // make entity type
    TCseObj bEntityTp(CseEmptyBuff);
    Cse_SetOption(bEntityTp,16);
    CseObj EnFlag = bEntityTp.append(TIntObj(1));
    EnFlag->iFlag = iLen2 + 1;
    bEntityTp.append(TCseObj(CUT_FROM,bCompTypes));
    bEntityTp.append(TCseObj(CUT_FROM,bCompTpInfo));
    bEntityTp.join(SuperEntityType,3);

    // create entity and save to SuperEntities
    TCseObj vCppEntity(CseEmptyBuff);
    _TEntity RetEntity;
    RetEntity->Id_ = bEntityTp;
    RetEntity->value = vCppEntity; // set C++ entity instance
    int iFrom = 0x7FFFFFFF;  // id for no cache
    if (NoCache == 0)
        ((TCseObj*)&SuperEntities)->bArray().add(RetEntity,&iFrom);
    TCseObj vEntityId = TIntObj(iFrom);

    // set entity head (EID) and regist current root 
    TObjArray& bCppEntity = vCppEntity.bArray();
    bCppEntity.resize(iLen2 + 1);
    bCppEntity.sub(0) = vEntityId;
    TCseObj vKey = TIntObj((TInt) GetCurrentThreadId());
    ((TCseObj*)&SuperCurrRoot)->set(vKey,vEntityId);

    // set every component instance
    for (int index2 = 1; index2 <= iLen2; index2++)
    {
        _TEntity CompObj = CreateOneEntity(bComponents.sub(index2-1));
        bCppEntity.sub(index2) = CompObj->value;
    }

    // clear current root
    ((TCseObj*)&SuperCurrRoot)->set(vKey,dummy);

    // trigger new-entity callback functions
    TObjArray& bCallback = ((TCseObj*)&SuperNewCallback)->bArray();
    int iLen3 = bCallback.len();
    for (int index3 = 0; index3 < iLen3; index3++)
    {
        _TEntity vFunc = (CseObj)bCallback.sub(index3);
        vFunc(RetEntity);  // vFunc: void callback(const _TEntity& me)
    }

    return RetEntity;
}

_TEntity t(const TMngStr& name)
{
    _TEntity RetObj;
    RetObj->Id_ = SuperSelectorType;

    int NameLen = name.len();
    if (NameLen == 0) return RetObj;  // undefined

    TInt ArrDim = 0;
    TCharArray sTypeName = name.sArray();
    while (NameLen >= 2 && name[NameLen-1] == _T('*'))
    {
        sTypeName = name.slice(0,NameLen-1);
        NameLen--;
        ArrDim++;
    }

    TObjArray bNameList;
    int iLast = 0;
    int iCurr = sTypeName.find(_T('.'),iLast);
    while (iCurr > 0)
    {
        if (iCurr > iLast)
            bNameList.append(TCseObj(sTypeName.slice(iLast,iCurr-iLast)).toId());
        iLast = iCurr + 1;
        iCurr = sTypeName.find(_T('.'),iLast);
    }
    if (NameLen > iLast)
        bNameList.append(TCseObj(sTypeName.slice(iLast,NameLen-iLast)).toId());

    int NameListLen = bNameList.len();
    for (int ii = 0; ii < NameListLen; ii++)
    {
        TCseObj TypeName = bNameList.sub(ii);
        if (ii == 0 && constUndefined == TypeName)
            return _TEntity();  // vRet->Id_ is CseSuper_unknown

        TBool exists = true;
        if (ii == 0)
        {
            TCseObj vSuperType = ((TCseObj*)&SuperComponents)->get(TypeName);
            if (dummy == vSuperType)
                exists = false;
            else RetObj->Id_ = vSuperType;
        }
        else
        {
            _TEntity en = CseSuper_EntityAttr(RetObj,TypeName,false,0);
            if (CseSuper_unknown == en->Id_)
            {
                en = CseSuper_EntityAttr(RetObj,TypeName,false,2);
                if (CseSuper_unknown == en->Id_)
                    exists = false;
                else RetObj = en;
            }
            else RetObj = en;
        }

        if (! exists)
            throw LOG_CSE_ERR(CSE_TYPE_ERR,_T("super type not exist: ") + name);
    }

    TCseObj SuperType = RetObj->Id_;
    ASSERT_TRUE(Cse_type(SuperType) == dtBuff && Cse_OptionOn(SuperType,16) && SuperType.len() > 0);

    int iFlag = SuperType.sub(0)->iValue;
    if (iFlag == 2)
    {   // global function
        ASSERT_TRUE(SuperType.len() >= 3);
        TCseObj FuncInfo = SuperType.sub(2);
        if (ArrDim == 0 && FuncInfo.len() >= 4)
        {
            RetObj->value = FuncInfo.sub(3);
            return RetObj;
        }
        throw LOG_CSE_ERR(CSE_SYSTEM_ERR,_T("super function format error"));
    }

    if (ArrDim)
    {
        TCseObj ArrType = CreateArrayType(TCseObj::format(CSE_WEAK,(CseObj)SuperType));
        while (--ArrDim > 0)
            ArrType = CreateArrayType(TCseObj::format(CSE_STRONG,(CseObj)ArrType));
        RetObj->Id_ = ArrType;
    }

    return RetObj;
}

_TEntity f(const TMngInt& addr, const TMngStr& sArgs, const TCseObj& bDefault)
{   // [stSuperFunc|size,retType,[dummy_weak(bOwner),sArgs], arg0 ...]
    TCseObj RetType;   // default is dummy
    TObjArray bArgs;   // default no argument
    TCharArray ArgDesc(sArgs);
    ArgDesc.trim();
    if (ArgDesc.len())
        ScanArguments(RetType,bArgs,ArgDesc);

    TCseObj bFuncType(CseEmptyBuff);
    Cse_SetOption(bFuncType,16);
    bFuncType.append(TIntObj(2));  // data size is 0

    bFuncType.append(RetType);
    TCseObj bInfo = bFuncType.append(CseEmptyBuff);
    bInfo.append(dummy);
    bInfo.append(TCseObj(CUT_FROM,ArgDesc));
    if (bDefault.len())
    {
        TCseObj bTmp = bInfo.append(CseEmptyBuff);
        bTmp.join(bDefault);
    }
    bFuncType.bArray().join(bArgs);

    TCseObj vFuncAddr = TIntObj(0xCCCCCCCC);
    vFuncAddr->iFlag = (TInt) addr;
    _TEntity vRet;
    vRet->Id_ = bFuncType;
    vRet->value = vFuncAddr;
    return vRet;
}

_TEntity f(const TMngInt& addr, TInt ArgNum, TXchar RetFlag, const TCseObj& bDefault)
{
    TCseObj RetType;   // default is dummy
    if (RetFlag == _T('i'))
        RetType = constI;
    else if (RetFlag == _T('v'))
        RetType = constV;
    else if (RetFlag == _T('w'))
        RetType = constW;
    else if (RetFlag == _T('f'))
        RetType = constF;
    else if (RetFlag == _T('s'))
        RetType = constS;
    else if (RetFlag == _T('t'))
        RetType = constT;
    else if (RetFlag == _T('b'))
        RetType = constB;
    else if (RetFlag == _T('d'))
        RetType = constD;
    // else, use defalut dummy (void)

    TObjArray bArgs(ArgNum);
    for (int i = 0; i < ArgNum; i++)
        bArgs.append(SuperWeakDummy);

    TCseObj bFuncType(CseEmptyBuff);
    Cse_SetOption(bFuncType,16);
    bFuncType.append(TIntObj(2));  // data size is 0
    bFuncType.append(RetType);
    TCseObj bInfo = bFuncType.append(CseEmptyBuff);
    bInfo.append(dummy);
    bInfo.append(SuperClosureArgs);
    if (bDefault.len())
    {
        TCseObj bTmp = bInfo.append(CseEmptyBuff);
        bTmp.join(bDefault);
    }
    bFuncType.bArray().join(bArgs);

    TCseObj vFuncAddr = TIntObj(0xCCCCCCCC);
    vFuncAddr->iFlag = (TInt) addr;
    _TEntity vRet;
    vRet->Id_ = bFuncType;
    vRet->value = vFuncAddr;
    return vRet;
}

}   // end of namespace __S

int CseSuper_len(const TCseObj& obj)
{
    CseObj value = obj;
    int tp = CSE_TYPE(value);

    if (tp == dtBuff)
    {
        CseObj AType;
        int n = CSE_ARRAY_LEN(value->bValue);
        if (n == 2 && Cse_type(AType = value->bValue[0]) == dtBuff && Cse_OptionOn(AType,16))
        {
            ASSERT_TRUE(CSE_ARRAY_LEN(AType->bValue) > 0 && AType->bValue[0]->iValue >= 1 && AType->bValue[0]->iValue <= 3);
            return obj.sub(1).len();  // get length of super-data content
        }
        else return n;
    }
    else if (tp == dtStr)
        return CSE_ARRAY_LEN(value->sValue);
    else if (tp == dtTier)
        return CSE_ARRAY_LEN(value->tValue);
    else if (tp == dtDict)
    {
        if (value->entry == NULL)
            return 0;
        else return CSE_ARRAY_LEN(value->entry);
    }
    else return 0;
}

int CseSuper_AddOnNew(const _TEntity& callback)
{
    ASSERT_TRUE(callback->Id_.optionOn(16) && callback->Id_.sub(0)->iValue == 2);

    int iRet;
    ((TCseObj*)&SuperNewCallback)->bArray().add(callback,&iRet);
    return iRet;
}

TCseObj EnsureSuperUdt(const TCseObj& Type)
{
    ASSERT_TRUE(Cse_type(Type) == dtId);
    TCseObj TypeObj = ((TCseObj*)&SuperComponents)->get(Type);

    // if Type inexistent, regist default one, use as forward declaration
    if (dummy == TypeObj)
        TypeObj = CseSuper_NewUdt(Type,0);
    return TCseObj::format(CSE_WEAK,(CseObj)TypeObj);
}

TCseObj CseSuper_NewArr(const TXchar *TypeName, const TXchar *ItemType, int dim)
{
    if (dim <= 0 || dim >= 16)
        throw LOG_CSE_ERR(CSE_VALUE_ERR,_T("create array type out of range"));

    TCseObj ItemName = TCseObj::format(CSE_ID,ItemType);
    TCseObj vType = EnsureSuperUdt(ItemName); // weak(AType)
    vType = CreateArrayType(vType);           // [3,0,weak_strong(AType),[method,...],[methodInfo,...]]
    while (--dim > 0)
        vType = CreateArrayType(TCseObj::format(CSE_STRONG,(CseObj)vType));

    TCseObj ArrName = TCseObj::format(CSE_ID,TypeName);
    ((TCseObj*)&SuperComponents)->set(ArrName,vType);
    return vType;
}

TCseObj CseSuper_NewUdt(const TCseObj& TypeName, TInt size)
{
    ASSERT_TRUE(Cse_type(TypeName) == dtId);

    TCseObj bInfo = ((TCseObj*)&SuperComponents)->get(TypeName);
    if (dummy == bInfo)
        bInfo = ((TCseObj*)&SuperComponents)->set(TypeName,CseEmptyBuff);
    else bInfo.clear();           // rewrite old one
    Cse_SetOption(bInfo,16);

    CseObj vFlag = bInfo.append(TIntObj(1));
    vFlag->iFlag = size / sizeof(CseObj);

    bInfo.append(CseEmptyBuff);   // bMembers
    bInfo.append(CseEmptyBuff);   // bMembInfo
    bInfo.append(CseEmptyBuff);   // bProtoFunc
    bInfo.append(CseEmptyBuff);   // bProtoInfo
    bInfo.append(TypeName);       // $TypeName
    return bInfo;
}

void SaveProtFuncAddr(const TCseObj& Type, const TCseObj& vFuncAddr)
{
    CHECK_MSG(Cse_type(Type) == dtBuff && Cse_OptionOn(Type,16) && Type.len() >= 3,_T("setup super-type error"));

    TCseObj FuncInfo = Type.sub(2);
    int FuncInfoLen = FuncInfo.len();
    if (FuncInfoLen == 2) 
    {
        FuncInfo.append(CseEmptyBuff);
        FuncInfo.append(vFuncAddr);
    }
    else if (FuncInfoLen == 3)
        FuncInfo.append(vFuncAddr);
    else
    {
        ASSERT_TRUE(FuncInfoLen >= 4);
        FuncInfo.sub(3) = vFuncAddr;
    }
}


void SuperAddMemb_( const TCseObj& bUdt, const TCseObj& Attr, const TCseObj& Type, 
     TInt offset, TInt BaseOff, TBool isArray, TBool isProtFunc = false, TBool ClsStatic = false )
{
    ASSERT_TRUE(Cse_type(Attr) == dtId);

    if (dummy == bUdt)
    {   // regist as global function
        CHECK_MSG(BaseOff > 0 && isProtFunc && !isArray,_T("only function can regist as global super data"));

        TCseObj vFuncAddr(TIntObj(0xCCCCCCCC));
        vFuncAddr->iFlag = offset;
        SaveProtFuncAddr(Type,vFuncAddr);

        ((TCseObj*)&SuperComponents)->set(Attr,Type);
        return;
    }

    TCseObj TypeObj;
    int TypeTp = Cse_type(Type);
    if (TypeTp == dtId)
    {
        TypeObj = EnsureSuperUdt(Type);
        if (isArray)
        {
            TCseObj bArrType = CreateArrayType(TypeObj);
            TypeObj = TCseObj::format(CSE_STRONG,(CseObj)bArrType);
        }
    }
    else
    {
        ASSERT_TRUE(! isArray);
        CHECK_MSG(TypeTp == dtBuff && Cse_OptionOn(Type,16),_T("setup super-type error"));
        TypeObj = TCseObj::format(CSE_STRONG,(CseObj)Type);  // hold it
    }

    ASSERT_TRUE(bUdt.len() > (2 + BaseOff) && bUdt.sub(0)->iValue == 1);
    TCseObj AttrList = bUdt.sub(1 + BaseOff);
    TCseObj TypeList = bUdt.sub(2 + BaseOff);

    int iAttrLen = AttrList.len();
    ASSERT_TRUE(iAttrLen * 2 == TypeList.len());

    TBool found = false;
    TUint iTarg = (TUint)(CseObj)Attr;
    CseObj *pObj = AttrList.bArray().addr();
    for (int i = 0; i < iAttrLen; i++,pObj++)
    {
        if (iTarg < (TUint)(*pObj))
        {   // save item in order
            int iPos = i * 2;
            AttrList.insert(i,Attr);
            TypeList.insert(iPos,TypeObj);

            CseObj vv;
            if (isProtFunc)
            {
                TCseObj vFuncAddr = TIntObj(0xCCCCCCCC);
                vFuncAddr->iFlag = offset;
                SaveProtFuncAddr(Type,vFuncAddr);

                vv = TypeList.insert(iPos,TCseObj::format(CSE_STRONG,(CseObj)vFuncAddr));
            }
            else vv = TypeList.insert(iPos,TIntObj(offset));
            if (ClsStatic) Cse_SetOption(vv,31);

            found = true;
            break;
        }
    }

    if (! found)
    {
        AttrList.append(Attr);

        CseObj vv;
        if (isProtFunc)
        {
            TCseObj vFuncAddr = TIntObj(0xCCCCCCCC);
            vFuncAddr->iFlag = offset;
            SaveProtFuncAddr(Type,vFuncAddr);

            vv = TypeList.append(TCseObj::format(CSE_STRONG,(CseObj)vFuncAddr));
        }
        else vv = TypeList.append(TIntObj(offset));
        TypeList.append(TypeObj);
        if (ClsStatic) Cse_SetOption(vv,31);
    }
}

void CseSuper_AddMemb(const TCseObj& bUdt, const TXchar *Attr, const TXchar *Type, TInt offset)
{
    TCseObj AttrName = TCseObj::format(CSE_ID,Attr);

    TBool isArray = false;
    TCharArray name(Type);
    if (name.len() >= 2 && name[-1] == _T('*'))
    {   // AType*
        isArray = true;
        name.remove(-1);
        name.trim();
        CHECK_MSG(name.len(),_T("type name can not NULL"));
    }

    TCseObj TypeName = TCseObj::format(CSE_ID,name.addr());
    SuperAddMemb_(bUdt,AttrName,TypeName,offset / sizeof(CseObj),0,isArray);
}

void ScanArguments(TCseObj& RetType, TObjArray& bArgs, const TCharArray& ArgDesc)
{   // (Type1 me,Type2 arg1,Type3* arg2,arg2) as AType
    // () as AType
    // (ANY)        or      EMPTY

    TBool ArgOk = true;
    TCharArray sRetType;
    int i1 = ArgDesc.find(_T("("));
    int i2 = ArgDesc.find(_T(")"));
    if (i1 >= 0 && i2 > i1)
    {
        TCharArray sArgPart = ArgDesc.slice(i1 + 1,i2 - i1 - 1);
        TCharArray sRetPart = ArgDesc.slice(i2 + 1);

        sRetPart.trim();
        if (sRetPart.len())
        {
            TObjArray bWords = sRetPart.split();
            int iWordNum = bWords.len();
            if (iWordNum == 0 && sRetPart[0] == _T(':'))
                sRetType = sRetPart.slice(1);
            else if (iWordNum == 1)
            {
                sRetType = bWords.sub(0).sArray();
                if (sRetType[0] == _T(':'))
                    sRetType.remove(0);
                else ArgOk = false;
            }
            else if (iWordNum == 2)
            {
                sRetType = bWords.sub(1).sArray();
                if (sRetType == _T("*"))
                {
                    sRetType = bWords.sub(0).sArray() + _T('*');
                    if (sRetType[0] == _T(':'))
                        sRetType.remove(0);
                    else ArgOk = false;
                }
                else 
                {
                    if (bWords.sub(0).sArray() != _T(":"))
                        ArgOk = false;
                }
            }
            else if (iWordNum == 3 && bWords.sub(0).sArray() == _T(":") && bWords.sub(2).sArray() == _T("*"))
                sRetType = bWords.sub(1).sArray() + _T('*');
            else ArgOk = false;
        }
        // else sRetType = _T("");

        sArgPart.trim();
        if (sArgPart.len())
        {
            TObjArray bWords = sArgPart.split(_T(","));
            if (bWords.len() == 0)
                bWords.append(sArgPart);

            int iWordsMax = bWords.len() - 1;
            for (int index = 0; index <= iWordsMax; index++)
            {
                TCharArray sItem = bWords.sub(index).sArray();
                sItem.trim();
                if (sItem[0] == _T('*'))
                {
                    bArgs.append(constEllipsis);  // var_list
                    break;
                }

                if (sItem.isEmpty() || sItem[-1] == _T('*'))
                {   // "AType*" is error, should use "AType* arg"
                    ArgOk = false;
                    break;
                }

                TObjArray bItems = sItem.split();
                int ItemLen = bItems.len();
                if (ItemLen == 0)  // only one word
                {
                    bArgs.append(SuperWeakDummy);    // TCseObj
                }
                else
                {
                    TCharArray OneArgName;
                    TCharArray OneArgType;

                    if (ItemLen == 1)
                    {   // ASSERT_TRUE(OneArgName[-1] != _T('*'));
                        OneArgName = bItems.sub(0).sArray();
                    }
                    else if (ItemLen == 2)
                    {
                        OneArgType = bItems.sub(0).sArray();
                        OneArgName = bItems.sub(1).sArray();
                        if (OneArgName.len() >= 2 && OneArgName[0] == _T('*'))
                        {
                            OneArgName.remove(0);
                            OneArgType += _T('*');
                        }
                    }
                    else if (ItemLen == 3 && bItems.sub(1).sArray() == _T("*"))
                    {
                        OneArgType = bItems.sub(0).sArray() + _T('*');
                        OneArgName = bItems.sub(1).sArray();
                    }
                    else
                    {
                        ArgOk = false;
                        break;
                    }

                    int ArgTpLen = OneArgType.len();
                    if (ArgTpLen > 0)
                    {
                        TXchar ch;
                        if (ArgTpLen == 1 && ( (ch = OneArgType[0]) == _T('i') || 
                            ch == _T('w') || ch == _T('f') || ch == _T('s') || ch == _T('t') || 
                            ch == _T('b') || ch == _T('d') || ch == _T('v') ) )
                        {   // keyword reserved: i w f s t b d v
                            bArgs.append(SuperWeakDummy);  // TCseObj
                        }
                        else
                        {
                            if (ArgTpLen >= 2 && OneArgType[-1] == _T('*'))
                            {
                                OneArgType.remove(-1);

                                TCseObj OneArgId = TCseObj::format(CSE_ID,OneArgType.addr());
                                TCseObj SubType = EnsureSuperUdt(OneArgId);
                                TCseObj bArrType = CreateArrayType(SubType);
                                bArgs.append(TCseObj::format(CSE_STRONG,(CseObj)bArrType));
                            }
                            else
                            {
                                TCseObj OneArgId = TCseObj::format(CSE_ID,OneArgType.addr());
                                if (constSObject == OneArgId)
                                    bArgs.append(SuperWeakDummy);
                                else bArgs.append(EnsureSuperUdt(OneArgId));
                            }
                        }
                    }
                    else
                    {
                        bArgs.append(SuperWeakDummy);  // TCseObj
                    }
                }
            }
        }
        // else, sArgPart = "", no argument
    }
    else ArgOk = false;

    if (! ArgOk)
        throw LOG_CSE_ERR(CSE_ARGS_ERR,_T("illegal argument:") + ArgDesc);

    int iRetTpLen = sRetType.len();
    if (iRetTpLen > 0)
    {
        if (iRetTpLen == 1)
        {   // reserved keyword: i w f s t b d v
            TXchar ch = sRetType[0];
            if (ch == _T('i'))
                RetType = constI;
            else if (ch == _T('v'))
                RetType = constV;
            else if (ch == _T('w'))
                RetType = constW;
            else if (ch == _T('f'))
                RetType = constF;
            else if (ch == _T('s'))
                RetType = constS;
            else if (ch == _T('t'))
                RetType = constT;
            else if (ch == _T('b'))
                RetType = constB;
            else if (ch == _T('d'))
                RetType = constD;
            else RetType = EnsureSuperUdt(TCseObj::format(CSE_ID,sRetType.addr()));
        }
        else
        {
            if (sRetType[-1] == _T('*'))
            {
                sRetType.remove(-1);
                sRetType.trim();
                CHECK_MSG(sRetType.len(),_T("return type name can not NULL"));

                TCseObj SubType = EnsureSuperUdt(TCseObj::format(CSE_ID,sRetType.addr()));
                TCseObj bArrType = CreateArrayType(SubType);
                RetType = TCseObj::format(CSE_STRONG,(CseObj)bArrType);
            }
            else
            {
                TCseObj RetTypeId = TCseObj::format(CSE_ID,sRetType.addr());
                if (constSObject == RetTypeId)
                    RetType = constV;
                else RetType = EnsureSuperUdt(RetTypeId);
            }
        }
    }
    // else, RetType = dummy;
}

void CseSuper_AddFunc( const TCseObj& bUdt, const TXchar *Attr, TInt addr, 
                       const TXchar *sArgs, const TCseObj& bDefault )
{   // result: [stSuperFunc|size,retType,[dummy_weak(owner),sArgs], arg0 ...]
    TCseObj RetType;    // default is dummy
    TObjArray bArgs;    // default no argument
    TCharArray ArgDesc(sArgs);
    ArgDesc.trim();
    if (ArgDesc.len())
        ScanArguments(RetType,bArgs,ArgDesc);

    TCseObj AttrName = TCseObj::format(CSE_ID,Attr);

    TCseObj bFuncType(CseEmptyBuff);
    Cse_SetOption(bFuncType,16);
    bFuncType.append(TIntObj(2));  // data size is 0

    bFuncType.append(RetType);
    TCseObj bInfo = bFuncType.append(CseEmptyBuff);
    bInfo.append(dummy);
    bInfo.append(TCseObj(CUT_FROM,ArgDesc));
    int DefLen = bDefault.len();
    if (DefLen)
    {
        int iFixLen = bArgs.len();
        int iVaArg = (iFixLen > 0 && constEllipsis == bArgs.sub(-1))? 1: 0;
        if (DefLen > iFixLen - iVaArg)
            throw LOG_CSE_ERR(CSE_ARGS_ERR,_T("too many default argument"));

        TCseObj bTmp = bInfo.append(CseEmptyBuff);
        bTmp.join(bDefault);
    }
    bFuncType.bArray().join(bArgs);

    SuperAddMemb_(bUdt,AttrName,bFuncType,addr/sizeof(CseObj),0,false);
}

void CseSuper_AddProt( const TCseObj& bUdt, const TXchar *Attr, TInt addr, 
        const TXchar *sArgs, const TXchar *Type, const TCseObj& bDefault, TBool ClsStatic )
{   // CseSuper_AddProt(bUdt,_T("MethodName"),METHOD_ADDR1(AClass,method),_T("(arg1,arg2)"),_T("AClass"));
    // CseSuper_AddProt(bUdt,_T("StaticMethodName"),ATTR_ADDR1(AClass,StaticMethod),_T("(arg1,arg2)"));
    // CseSuper_AddProt(bUdt,_T("StaticMembName"),ATTR_ADDR1(AClass,StaticMember),NULL,_T("MembType"));
    TCseObj AttrName = TCseObj::format(CSE_ID,Attr);

    if (sArgs == NULL || sArgs[0] == _T('\0'))
    {   // it is static member
        ASSERT_TRUE(Type != NULL && Type[0] != _T('\0'));
        TCseObj TypeName = TCseObj::format(CSE_ID,Type);
        SuperAddMemb_(bUdt,AttrName,TypeName,addr,2,false,false,ClsStatic);
        return;
    }
    // else, is method or static method

    TCharArray sTypeDesc(Type);
    TCseObj OwnerType;
    sTypeDesc.trim();
    if (sTypeDesc.len())
        OwnerType = EnsureSuperUdt(TCseObj(sTypeDesc).toId());

    // result: [stSuperFunc|size,retType,[dummy_weak(owner),sArgs,bDefault], arg0 ...]
    TCseObj RetType;   // default is dummy
    TObjArray bArgs;   // default no argument
    TCharArray ArgDesc(sArgs);
    ArgDesc.trim();
    if (ArgDesc.len())
        ScanArguments(RetType,bArgs,ArgDesc);

    TCseObj bFuncType(CseEmptyBuff);
    Cse_SetOption(bFuncType,16);
    bFuncType.append(TIntObj(2)); // data size is 0

    bFuncType.append(RetType);
    TCseObj bInfo = bFuncType.append(CseEmptyBuff);
    bInfo.append(OwnerType);
    bInfo.append(TCseObj(CUT_FROM,ArgDesc));
    int DefLen = bDefault.len();
    if (DefLen)
    {
        int iFixLen = bArgs.len();
        int iVaArg = (iFixLen > 0 && constEllipsis == bArgs.sub(-1))? 1: 0;
        if (DefLen > iFixLen - iVaArg)
            throw LOG_CSE_ERR(CSE_ARGS_ERR,_T("too many default argument"));

        TCseObj bTmp = bInfo.append(CseEmptyBuff);
        bTmp.join(bDefault);
    }
    bFuncType.bArray().join(bArgs);

    SuperAddMemb_(bUdt,AttrName,bFuncType,addr,2,false,true,ClsStatic && (dummy == OwnerType));
}

SClosure::SClosure(const _TEntity& func, const TCseObj& env) : TCseObj(CseEmptyBuff)
{
    ASSERT_TRUE(Cse_type(env) == dtBuff && env.len() > 0);

    CseObj bType = func->Id_;
    ASSERT_TRUE( Cse_type(bType) == dtBuff && Cse_OptionOn(bType,16));

    CHECK_MSG(CSE_ARRAY_LEN(bType->bValue) >= 3 && bType->bValue[0]->iValue == 2,_T("closure function format error"));
    ASSERT_TRUE(Cse_type(bType->bValue[2]) == dtBuff && Cse_len(bType->bValue[2]) > 0);
    CHECK_MSG(dummy == bType->bValue[2]->bValue[0],_T("thiscall can not use as closure function"));

    append(func);
    append(env);
    Cse_SetOption(m_data,20);
}

SClosure::SClosure(const SClosure& obj): TCseObj(obj.m_data)
{
}

TCseObj SClosure::operator()(const TCseObj& args) const
{
    TCseObj bArgs(CseEmptyBuff);
    bArgs.join(args);
    bArgs.append(sub(1));

    _TEntity fn = (CseObj)sub(0);
    return fn.call(bArgs);
}

// Cse_ClearSuperObjs / Cse_ClearSuperTypes / Cse_SetSuperTypes()
//-----------------------------------------------------------------------------
STATIC TCseObj SuperPureValue(const TCseObj& value)
{
    int tp = Cse_type(value);
    if (tp == dtBuff && value.len() == 2)
    {
        CseObj bType = value.sub(0);
        if (Cse_OptionOn(bType,16) && CSE_TYPE(bType) == dtBuff && CSE_ARRAY_LEN(bType->bValue) > 0)
        {
            TInt iFlag = bType->bValue[0]->iValue;
            if (iFlag == 1 || iFlag == 2 || iFlag == 3)
                return value.sub(1);
            else if (CseSuper_unknown == bType)
                return CseSuper_unknown;
        }
    }
    return value;
}

static TCseObj GetIntNumFromStr(int& tp, const TCharArray& sIn, TInt radix)
{
    TCharArray s = sIn;
    s.trim();
    int iLen = s.len();

    TBool negated = false;           // +
    if (iLen >= 1)
    {
        TXchar ch = s[0];
        if (ch == _T('-'))
        {
            negated = true;
            s.remove(0);
            iLen--;
        }
        else if (ch == _T('+'))
        {
            s.remove(0);
            iLen--;
        }
    }

    TXchar ch1;
    if (iLen > 2 && s[0] == _T('0') && ((ch1 = s[1]) == _T('x') || ch1 == _T('X')))
    {   // 0x  or 0X
        TXchar *sourPtr = s.addr();
        TXchar *RetPtr = sourPtr;
        TUlong iResult = STRTOUL(sourPtr,&RetPtr,0);
        if (RetPtr > sourPtr)  // (RetPtr > sourPtr && (RetPtr - sourPtr) == iLen)
        {
            TUint IntRange = 0x01 << (sizeof(TInt) * 8 - 1);
            if (iResult >= IntRange)
            {
                TWint ii = iResult;
                if (negated) ii = -ii;
                tp = dtWint;
                return TWintObj(ii);
            }
            else
            {
                TInt ii = (TInt)iResult;
                if (negated) ii = -ii;
                tp = dtInt;
                return TIntObj(ii);
            }
        }
        // else, convert error
    }
    else
    {
        TXchar *sourPtr = s.addr();
        TXchar *RetPtr = sourPtr;
        TLong iResult = STRTOL(sourPtr,&RetPtr,radix);
        if (RetPtr > sourPtr)  // (RetPtr > sourPtr && (RetPtr - sourPtr) == iLen)
        {
            if (negated) iResult = -iResult;
            tp = dtInt;
            return TIntObj(iResult);
        }
        // else, convert error
    }

    tp = dtNull;
    return dummy; 
}

static TCseObj GetFloatNumFromStr(int& tp, const TCharArray& sIn)
{
    TCharArray s = sIn;
    s.trim();
    int iLen = s.len();

    TBool negated = false;       // +
    if (iLen >= 1)
    {
        TXchar ch = s[0];
        if (ch == _T('-'))
        {
            negated = true;
            s.remove(0);
            iLen--;
        }
        else if (ch == _T('+'))
        {
            s.remove(0);
            iLen--;
        }
    }

    TXchar ch1;
    if (iLen > 2 && s[0] == _T('0') && ((ch1 = s[1]) == _T('x') || ch1 == _T('X')))
    {   // 0x  or 0X
        TXchar *sourPtr = s.addr();
        TXchar *RetPtr = sourPtr;
        TUlong iResult = STRTOUL(sourPtr,&RetPtr,0);
        if (RetPtr > sourPtr)  // (RetPtr > sourPtr && (RetPtr - sourPtr) == iLen)
        {
            TUint IntRange = 0x01 << (sizeof(TInt) * 8 - 1);
            if (iResult >= IntRange)
            {
                TWint ii = iResult;
                if (negated) ii = -ii;
                tp = dtFloat;
                return TFloatObj((TDouble)ii);
            }
            else
            {
                TInt ii = (TInt)iResult;
                if (negated) ii = -ii;
                tp = dtFloat;
                return TFloatObj((TDouble)ii);
            }
        }
        // else, convert error
    }
    else
    {
        TXchar *sourPtr = s.addr();
        TXchar *RetPtr = sourPtr;
        TDouble fResult = STRTOD(sourPtr,&RetPtr);
        if (RetPtr > sourPtr)  // (RetPtr > sourPtr && (RetPtr - sourPtr) == iLen)
        {
            if (negated) fResult = -fResult;
            tp = dtFloat;
            return TFloatObj(fResult);
        }
        // else, convert error
    }

    tp = dtNull;
    return dummy;
}

namespace __S
{

TCseObj parseInt(const TCseObj& value, const TMngInt& radix)
{
    TCseObj v = SuperPureValue(value);
    if (dummy == v) return TCseObj::format(CSE_WEAK,0);

    int tp = Cse_type(v);
    if (tp == dtInt || tp == dtWint)
        return v;
    else if (tp == dtFloat)
        return TIntObj((TInt)v->fValue);
    else if (tp == dtStr)
    {
        TCseObj vv = GetIntNumFromStr(tp,v.sArray(),radix);
        if (tp == dtInt || tp == dtWint)
            return vv;
        // else, convert error
    }
    return TCseObj::format(CSE_WEAK,0);
}

TCseObj parseFloat(const TCseObj& value)
{
    TCseObj v = SuperPureValue(value);
    if (dummy == v) return TCseObj::format(CSE_WEAK,0);

    int tp = Cse_type(v);
    if (tp == dtInt)
        return TFloatObj((TDouble)v->iValue);
    else if (tp == dtWint)
        return TFloatObj((TDouble)v->wValue);
    else if (tp == dtFloat)
        return TFloatObj(v->fValue); // create new TCseObj
    else if (tp == dtStr)
    {
        TCseObj vv = GetFloatNumFromStr(tp,v.sArray());
        if (tp == dtFloat)
            return vv;
        // else, convert error
    }
    return TCseObj::format(CSE_WEAK,0);
}

TIntObj isNaN(const TCseObj& value)
{
    if (dummy == value)
        return 1;

    TCseObj v = SuperPureValue(value);
    int tp = Cse_type(v);
    if (tp == dtInt || tp == dtWint || tp == dtFloat)
        return 0;
    else if (tp == dtStr)
    {
        TCseObj v2 = parseFloat(v);
        if (Cse_type(v2) == dtWeak)
        {
            v2 = parseInt(v);
            if (Cse_type(v2) != dtWeak)
                return 0;
        }
        else return 0;
    }
    return 1;
}

TIntObj cachedNum()
{
    return ((TCseObj*)&SuperEntities)->len();
}

_TEntity rootEntity()
{
    TCseObj vKey = TIntObj((TInt) GetCurrentThreadId());
    TCseObj vValue = ((TCseObj*)&SuperCurrRoot)->get(vKey);

    if (dummy == vValue)
        return *CseSuper_UnknownObj;
    else
    {
        ASSERT_TRUE(vValue->iValue >= 0 && (TUint)vValue->iValue < CSE_ARRAY_LEN(SuperEntities->bValue));
        return SuperEntities->bValue[vValue->iValue];
    }
}

_TLinker linkTo(const TXchar* attr)
{
    return linkTo(TCseObj::format(CSE_ID,attr));
}

_TLinker linkTo(const TCseObj& attr)
{
    TCseObj vKey = TIntObj((TInt) GetCurrentThreadId());
    CseObj vValue = ((TCseObj*)&SuperCurrRoot)->get(vKey);

    if (dummy != vValue)
    {
        TUint32 iFlag = (TUint32) vValue->iValue;  // eid
        ASSERT_TRUE(iFlag < CSE_ARRAY_LEN(SuperEntities->bValue));

        _TEntity en = SuperEntities->bValue[iFlag];
        TCseObj name = attr.toId();
        TInt offset = 0;
        _TEntity memb = CseSuper_EntityAttr(en,name,true,0,&offset);

        iFlag |= (TUint32)(offset << 16);

        _TLinker vRet;  // weak(bType,iFlag)
        vRet->vValue = memb->Id_;
        vRet->iFlag = iFlag;
        return vRet;
    }

    throw LOG_CSE_ERR(CSE_RUNTIME_ERR,_T("get root entity failed"));
}

}   // end of namespace __S

TMngInt::TMngInt(CseObj v): TCseObj(v)
{
    TBool succ = true;
    int tp = CSE_TYPE(m_data);
    if (tp == dtInt)
        ;  // do nothing
    else if (tp == dtWint)
        *(TCseObj*)this = TIntObj((TInt)m_data->wValue);
    else if (tp == dtFloat)
        *(TCseObj*)this = TIntObj((TInt)m_data->fValue);
    else if (tp == dtStr)
    {
        TCseObj vv = GetIntNumFromStr(tp,sArray(),0);
        if (tp == dtInt)
            *(TCseObj*)this = vv;
        else if (tp == dtWint)
            *(TCseObj*)this = TIntObj((TInt)vv->wValue);
        else succ = false;
    }
    else succ = false;

    if (! succ)
        throw LOG_CSE_ERR(CSE_TYPE_ERR,_T("content of TMngInt should be dtInt"));
}

TMngWint::TMngWint(CseObj v): TCseObj(v)
{
    TBool succ = true;
    int tp = CSE_TYPE(m_data);
    if (tp == dtWint)
        ;  // do nothing
    else if (tp == dtInt)
        *(TCseObj*)this = TWintObj((TWint)m_data->iValue);
    else if (tp == dtFloat)
        *(TCseObj*)this = TWintObj((TWint)m_data->fValue);
    else if (tp == dtStr)
    {
        TCseObj vv = GetIntNumFromStr(tp,sArray(),0);
        if (tp == dtWint)
            *(TCseObj*)this = vv;
        else if (tp == dtInt)
            *(TCseObj*)this = TWintObj((TWint)vv->iValue);
        else succ = false;
    }
    else succ = false;

    if (! succ)
        throw LOG_CSE_ERR(CSE_TYPE_ERR,_T("content of TMngWint should be dtWint"));
}

TMngFloat::TMngFloat(CseObj v): TCseObj(v)
{
    TBool succ = true;
    int tp = CSE_TYPE(m_data);
    if (tp == dtFloat)
        ;  // do nothing
    else if (tp == dtInt)
        *(TCseObj*)this = TFloatObj((TDouble)m_data->iValue);
    else if (tp == dtWint)
        *(TCseObj*)this = TFloatObj((TDouble)m_data->wValue);
    else if (tp == dtStr)
    {
        TCseObj vv = GetFloatNumFromStr(tp,sArray());
        if (tp == dtFloat)
            *(TCseObj*)this = vv;
        else succ = false;
    }
    else succ = false;

    if (! succ)
        throw LOG_CSE_ERR(CSE_TYPE_ERR,_T("content of TMngFloat should be dtFloat"));
}

static TXchar *ToFixedFrmt[21] = {
    _T("%.0f"), _T("%.1f"), _T("%.2f"), _T("%.3f"), _T("%.4f"),
    _T("%.5f"), _T("%.6f"), _T("%.7f"), _T("%.8f"), _T("%.9f"),
    _T("%.10f"),_T("%.11f"),_T("%.12f"),_T("%.13f"),_T("%.14f"),
    _T("%.15f"),_T("%.16f"),_T("%.17f"),_T("%.18f"),_T("%.19f"),_T("%.20f") };

static TXchar *ToExponFrmt[21] = {
    _T("%.0e"), _T("%.1e"), _T("%.2e"), _T("%.3e"), _T("%.4e"),
    _T("%.5e"), _T("%.6e"), _T("%.7e"), _T("%.8e"), _T("%.9e"),
    _T("%.10e"),_T("%.11e"),_T("%.12e"),_T("%.13e"),_T("%.14e"),
    _T("%.15e"),_T("%.16e"),_T("%.17e"),_T("%.18e"),_T("%.19e"),_T("%.20e") };

static TXchar *ToPreciFrmt[21] = {
    _T("%.1g"), _T("%.2g"), _T("%.3g"), _T("%.4g"), _T("%.5g"),
    _T("%.6g"), _T("%.7g"), _T("%.8g"), _T("%.9g"), _T("%.10g"),
    _T("%.11g"),_T("%.12g"),_T("%.13g"),_T("%.14g"),_T("%.15g"),
    _T("%.16g"),_T("%.17g"),_T("%.18g"),_T("%.19g"),_T("%.20g"),_T("%.21g") };

TCseException LogPrecisionErr()
{
    return LOG_CSE_ERR(CSE_RANGE_ERR,_T("precision number out of range"));
}

TCharArray TMngFloat::toFixed(const TMngInt& num) const
{
    if (num >= 0 && num <= 20)
        return TCharArray::format(ToFixedFrmt[num],(TDouble)(*this));
    else throw LogPrecisionErr();
}

TCharArray TMngFloat::toExponential(const TMngInt& num) const
{
    if (num >= 0 && num <= 20)
        return TCharArray::format(ToExponFrmt[num],(TDouble)(*this));
    else throw LogPrecisionErr();
}

TCharArray TMngFloat::toPrecision(const TMngInt& num) const
{
    if (num >= 1 && num <= 21)
        return TCharArray::format(ToPreciFrmt[num-1],(TDouble)(*this));
    else throw LogPrecisionErr();
}

TIntObj TMngStr::operator()(const TMngInt& index, const TCseObj& value) const
{
    if (dummy == value)
    {   // read
        return (TInt)sub(index);
    }
    else
    {   // write
        TXchar ch;
        int tp = Cse_type(value);
        if (tp == dtInt)
            ch = (TXchar) value->iValue;
        else if (tp == dtWint)
            ch = (TXchar) value->wValue;
        else if (tp == dtStr)
            ch = value->sValue[0];
        else throw LOG_CSE_ERR(CSE_TYPE_ERR,_T("invalid value assign to TMngStr[n]"));

        sub(index) = ch;
        return (TInt) ch;
    }
}

TMngStr TMngStr::concat(const TMngStr& s) const
{
    TCharArray sRet = sArray() + s.sArray();
    return TMngStr(CUT_FROM,sRet);
}

TIntObj TMngStr::indexOf(const TMngStr& sSub,const TMngInt& iFrom) const
{
    return find(sSub.addr(),iFrom);
}

TMngStr TMngStr::replaceOf(const TMngStr& sSub,const TMngStr& sReplace,const TMngInt& count) const
{
    TCharArray sRet(sSub.sArray());
    sRet.replace(sSub.addr(),sReplace.addr(),count);
    return TMngStr(CUT_FROM,sRet);
}

TMngStr TMngStr::sliceOf(const TMngInt& index, const TMngInt& iLen) const
{
    TCharArray sRet = slice(index,iLen);
    return TMngStr(CUT_FROM,sRet);
}

TObjArray TMngStr::splitOf(const TMngStr& sSub,const TMngInt& iLimit) const
{
    int count = iLimit;
    if (count == 0) return CseEmptyBuff;

    TCharArray& s = sArray();
    int iSourLen = s.len();
    if (iSourLen == 0) return CseEmptyBuff;

    TCharArray& sSplit = sSub.sArray();
    int iSubLen = sSplit.len();
    if (iSubLen == 0)
    {   // split every char
        TObjArray bTmp;

        void *pIter = NULL;
        TXchar ch;
        while (s.enumItem(pIter,&ch))
            bTmp.append(TCharArray(ch));
        return TObjArray(CUT_FROM,bTmp);
    }
    else
    {
        if (iSubLen < iSourLen)
        {
            TObjArray bTmp = s.split(sSub.addr(),count,true);
            if (bTmp.len() == 0)
            {
                // ASSERT_TRUE(count< 0 || count > 0);
                bTmp.append(s);                // if not found, append self string
            }
            return TObjArray(CUT_FROM,bTmp);
        }
        else 
        {
            // ASSERT_TRUE(count< 0 || count > 0);
            TObjArray bTmp;
            if (iSubLen == iSourLen)
            {
                if (s == sSplit)
                {
                    bTmp.append(CseEmptyStr);     // means head-match
                    if (count < 0 || count >= 2)
                        bTmp.append(CseEmptyStr); // means tail-match
                }
                else bTmp.append(s);              // not found, append self string
            }
            else bTmp.append(s);                  // iSubLen >= iSourLen, append self string
            return TObjArray(CUT_FROM,bTmp);
        }
    }
}

TMngStr TMngStr::toLowerCase() const
{
    return sArray().toLower();
}

TMngStr TMngStr::toUpperCase() const
{
    return sArray().toUpper();
}

TMngStr TMngStr::toTrim() const
{
    TCharArray s(sArray());  // copy self string
    s.trim();
    return TMngStr(CUT_FROM,s);
}

TIntObj TMngTier::operator()(const TMngInt& index, const TCseObj& value) const
{
    if (dummy == value)
    {   // read
        return sub(index);
    }
    else
    {   // write
        TInt ii;
        TBool succ = true;

        int tp = Cse_type(value);
        if (tp == dtStr)
        {
            TCseObj v = __S::parseInt(value);
            tp = Cse_type(v);
            if (tp == dtInt)
                ii = value->iValue;
            else if (tp == dtWint)
                ii = (TInt) value->wValue;
            else succ = false;
        }
        else if (tp == dtInt)
            ii = value->iValue;
        else if (tp == dtWint)
            ii = (TInt) value->wValue;
        else succ = false;

        if (! succ)
            throw LOG_CSE_ERR(CSE_TYPE_ERR,_T("invalid value assign to TMngTier[n]"));

        sub(index) = ii;
        return ii;
    }
}

TIntObj TMngTier::push(const TMngInt& value, const TCseObj& args) const
{
    int iRet = 0;
    TInt iValue = value;
    TIntArray& tList = tArray();
    tList.add(iValue,&iRet);

    TObjArray& bArgs = args.bArray();
    int iLen = bArgs.len();
    for (int i = 0; i < iLen; i++)
    {
        CseObj item = bArgs.sub(i);

        int tp = Cse_type(item);
        if (tp == dtInt)
            iValue = item->iValue;
        else if (tp == dtWint)
            iValue = (TInt) item->wValue;
        else if (tp == dtFloat)
            iValue = (TInt) item->fValue;
        else iValue = (TInt) item;

        tList.add(iValue,&iRet);
    }

    return iRet + 1;
}

TIntObj TMngTier::pop(const TMngInt& index) const
{
    extern TInt CseTier_pop(TIntArray& tArray, int index);
    return CseTier_pop(tArray(),index);
}

TIntObj TMngTier::shift() const
{
    extern TInt CseTier_pop(TIntArray& tArray, int index);
    return CseTier_pop(tArray(),0);
}

TIntObj TMngTier::unshift(const TMngInt& value, const TCseObj& args) const
{
    TInt iValue = value;
    TIntArray& tList = tArray();
    int iRet = tList.insert_(0,iValue);

    TObjArray& bArgs = args.bArray();
    for (int i = bArgs.len() - 1; i >= 0; i--)
    {
        CseObj item = bArgs.sub(i);

        int tp = Cse_type(item);
        if (tp == dtInt)
            iValue = item->iValue;
        else if (tp == dtWint)
            iValue = (TInt) item->wValue;
        else if (tp == dtFloat)
            iValue = (TInt) item->fValue;
        else iValue = (TInt) item;

        iRet = tList.insert_(1,iValue);
    }

    return iRet;
}

TMngTier TMngTier::concat(const TMngTier& that) const
{
    TIntArray tArr = tArray();
    tArr.join(that.tArray());
    return TMngTier(CUT_FROM,tArr);
}

TMngTier TMngTier::sliceOf(const TMngInt& index, const TMngInt& iLen) const
{
    TIntArray tArr = slice(index,iLen);
    return TMngTier(CUT_FROM,tArr);
}

TCharArray TMngTier::desc(const TMngStr& separator) const
{
    void *pIter = NULL;
    TIntArray& tArr = tArray();

    TCharArray ret(_T("("));
    TInt item;
    int iCount = 0;
    while (tArr.enumItem(pIter,&item))
    {
        TXchar buff[256];
        if (iCount == 0)
            SPRINTF(buff,_T("%d"),item);
        else SPRINTF(buff,_T("%s%d"),separator.addr(),item);

        ret += buff;
        iCount++;
    }
    if (iCount == 1) ret += separator;
    ret += _T(')');

    return TCharArray(CUT_FROM,ret);
}

TMngTier TMngTier::reverse() const
{
    TIntArray& tArr = tArray();
    TIntArray tTmp;
    tTmp.join(tArr);
    tArr.truncate(0);

    void *pIter = NULL;
    TInt value;
    while (tTmp.enumItem(pIter,&value))
        tArr.insert(0,value);

    return *this;
}

TMngTier TMngTier::splice(const TMngInt& iStart,const TMngInt& iDelNum,const TCseObj& args) const
{
    int iBegin = iStart;
    int iDel = iDelNum;
    if (iDel < 0) iDel = len();
    
    TIntArray tTmp = slice(iBegin,iDel);
    remove(iBegin,tTmp.len());

    TObjArray& bItem = args.bArray();
    TCseObj vItem;
    void *pIter = NULL;
    while (bItem.enumItem(pIter,&vItem))
    {
        TBool succ = true;
        int tp = Cse_type(vItem);
        if (tp == dtInt)
            insert(iBegin,vItem->iValue);
        else if (tp == dtWint)
            insert(iBegin,(TInt)vItem->wValue);
        else if (tp == dtStr)
        {
            TCseObj vv = __S::parseInt(vItem);
            tp = Cse_type(vv);
            if (tp == dtInt)
                insert(iBegin,vv->iValue);
            else if (tp == dtWint)
                insert(iBegin,(TInt)vv->wValue);
            else succ = false;
        }
        else succ = false;
        
        if (! succ)
            throw LOG_CSE_ERR(CSE_VALUE_ERR,_T("TMngTier[n] should be int"));
        iBegin++;
    }

    return TMngTier(CUT_FROM,tTmp);
}

TCseObj TMngBuff::operator()(const TMngInt& index, const TCseObj& value) const
{
    if (dummy == value)
    {   // read
        return sub(index);
    }
    else
    {   // write
        TCseObj v = SuperPureValue(value);
        sub(index) = v;
        return v;
    }
}

TIntObj TMngBuff::push(const TCseObj& value, const TCseObj& args) const
{
    int iRet;
    add(SuperPureValue(value),&iRet);

    TObjArray& bArgs = args.bArray();
    int iLen = bArgs.len();
    for (int i = 0; i < iLen; i++)
        add(SuperPureValue(bArgs.sub(i)),&iRet);

    return iRet + 1;
}

TCseObj TMngBuff::pop(const TMngInt& index) const
{
    return bArray().pop(index);
}

TCseObj TMngBuff::shift() const
{
    return bArray().pop(0);
}

TIntObj TMngBuff::unshift(const TCseObj& value, const TCseObj& args) const
{
    TObjArray& bList = bArray();
    int iRet = bList.insert_(0,SuperPureValue(value));

    TObjArray& bArgs = args.bArray();
    for (int i = bArgs.len() - 1; i >= 0; i--)
        iRet = bList.insert_(1,SuperPureValue(bArgs.sub(i)));

    return iRet;
}

TMngBuff TMngBuff::concat(const TMngBuff& that) const
{
    TObjArray bArr = bArray();
    bArr.join(that.bArray());
    return TMngBuff(CUT_FROM,bArr);
}

TMngBuff TMngBuff::sliceOf(const TMngInt& index, const TMngInt& iLen) const
{
    TObjArray bArr = slice(index,iLen);
    return TMngBuff(CUT_FROM,bArr);
}

TCharArray TMngBuff::desc(const TMngStr& separator) const
{
    void *pIter = NULL;
    TObjArray& bArr = bArray();

    TCharArray ret(_T("["));
    TCseObj item;
    int iCount = 0;
    while (bArr.enumItem(pIter,&item))
    {
        if (iCount == 0)
            ret += item.str();
        else ret += separator + item.str();
        iCount++;
    }
    ret += _T(']');

    return TCharArray(CUT_FROM,ret);
}

TMngBuff TMngBuff::reverse() const
{
    TObjArray& bArr = bArray();
    TObjArray bTmp;
    bTmp.join(bArr);
    bArr.truncate(0);

    void *pIter = NULL;
    TCseObj value;
    while (bTmp.enumItem(pIter,&value))
        bArr.insert(0,value);

    return *this;
}

TMngBuff TMngBuff::splice(const TMngInt& iStart,const TMngInt& iDelNum,const TCseObj& args) const
{
    int iBegin = iStart;
    int iDel = iDelNum;
    if (iDel < 0) iDel = len();
    
    TObjArray bTmp = slice(iBegin,iDel);
    remove(iBegin,bTmp.len());

    TObjArray& bItem = args.bArray();
    TCseObj vItem;
    void *pIter = NULL;
    while (bItem.enumItem(pIter,&vItem))
    {
        TBool succ = true;
        insert(iBegin,SuperPureValue(vItem));
        iBegin++;
    }

    return TMngBuff(CUT_FROM,bTmp);
}

TCseObj TMngDict::operator()(const TCseObj& key, const TCseObj& value) const
{
    if (dummy == value)
    {   // read
        TCseObj v = get(key);
        if (dummy == v)
            return CseSuper_unknown;
        else return v;
    }
    else
    {   // write
        TCseObj v = SuperPureValue(value);
        if (CseSuper_unknown == v)
            set(key,dummy);
        else set(key,v);
        return v;
    }
}

TCharArray TMngDict::desc(const TMngStr& separator) const
{
    PEntryPoint pEntry = NULL;
    TEntryArray& dArr = dArray();

    TCharArray ret(_T("{"));
    TCseObj key,value;
    int iCount = 0;
    while (dArr.enumItem(pEntry,&key,&value))
    {
        if (iCount > 0) ret += separator;
        ret += key.str() + _T(":") + value.str();
        iCount++;
    }
    ret += _T('}');

    return TCharArray(CUT_FROM,ret);
}

void Cse_ClearSuperObjs()
{
    // step 1: free all entity
    TCseObj bSuperObj(SuperEntities);
    int index = bSuperObj.len() - 1;
    while (index >= 0)
    {
        bSuperObj.sub(index) = dummy;
        index--;
    }
    bSuperObj.clear();

    // step 2: clear all registed events
    PEntryPoint pEntity = NULL;
    TEntryArray& dArray = ((TCseObj*)&SuperEvents)->dArray();
    TCseObj item;
    while (dArray.enumItem(pEntity,NULL,&item))
    {
        ASSERT_TRUE(Cse_type(item) == dtDict);

        TEntryArray& dArray2 = item.dArray();
        PEntryPoint pEntity2 = NULL;
        TCseObj EvFuncs;
        while (dArray2.enumItem(pEntity2,NULL,&EvFuncs))
            EvFuncs.clear();

        item.clear();
    }
    dArray.clear();

    // step 3: disconnect script system
    SuperConvertFunc = NULL;
}

void Cse_ClearSuperTypes()
{
    TCseObj(SuperCurrRoot).clear();
    TCseObj(SuperNewCallback).clear();

    TCseObj dSuperComp(SuperComponents);
    PEntryPoint pEntry = NULL;
    TCseObj value;
    while (dSuperComp.enumItem(pEntry,NULL,&value))
    {
        if (Cse_type(value) == dtBuff)
            value.clear();
    }
    dSuperComp.clear();

    if (CseSuper_UnknownObj != NULL)
    {
        delete CseSuper_UnknownObj;
        CseSuper_UnknownObj = NULL;
    }
}

void Cse_SetSuperTypes()
{
    constInit        = CseRegist_StolenHold(CseId_new(_T("init")));
    constRemove      = CseRegist_StolenHold(CseId_new(_T("remove")));
    constOpCall      = CseRegist_StolenHold(CseId_new(_T("operator()")));
    constEllipsis    = CseRegist_StolenHold(CseId_new(_T("...")));
    constSObject     = CseRegist_StolenHold(CseId_new(_T("SObject")));
    constUndefined   = CseRegist_StolenHold(CseId_new(_T("undefined")));
    constI           = CseRegist_StolenHold(CseId_new(_T("i")));
    constW           = CseRegist_StolenHold(CseId_new(_T("w")));
    constF           = CseRegist_StolenHold(CseId_new(_T("f")));
    constS           = CseRegist_StolenHold(CseId_new(_T("s")));
    constT           = CseRegist_StolenHold(CseId_new(_T("t")));
    constB           = CseRegist_StolenHold(CseId_new(_T("b")));
    constD           = CseRegist_StolenHold(CseId_new(_T("d")));
    constV           = CseRegist_StolenHold(CseId_new(_T("v")));

    SuperWeakDummy   = CseRegist_StolenHold(CseWeak_new(dummy,0));
    SuperComponents  = CseRegist_StolenHold(CseDict_new());
    SuperEntities    = CseRegist_StolenHold(CseBuff_new(0));
    SuperEvents      = CseRegist_StolenHold(CseDict_new());
    SuperCurrRoot    = CseRegist_StolenHold(CseDict_new());
    SuperNewCallback = CseRegist_StolenHold(CseBuff_new(0));

    SuperClosureArgs = CseRegist_StolenHold(CseStr_new(_T("(*args)")));

    SuperConvertFunc = CseRegist_StolenSet(_T("KERNEL/SUPER_ARG_CONVERT"),CseInt_new(0));
    CseSuper_unknown = CseRegist_StolenHold(CseBuff_new(0));
    Cse_SetOption(CseSuper_unknown,16);
    CseBuff_StolenAppend(CseSuper_unknown,CseInt_new(0));

    CseSuper_UnknownObj = new _TEntity();
    (*CseSuper_UnknownObj)->value = CseSuper_unknown;

    TCseObj bDefaultArg(CseEmptyBuff);
    TCseObj bSuperType = CseRegist_StolenSet(_T("KERNEL/SUPER_RSVD_TYPE"),CseBuff_new(0));

    // _TEntity
    TXchar *CompName = _T("Entity"); TEntityType component = TEntityType(CompName,sizeof(_TEntity::m));
    component.addProt(_T("eid"),ATTR_ADDR1(_TEntity,eid),_T("(Entity me):i"),CompName);
    component.addProt(_T("has"),ATTR_ADDR1(_TEntity,has),_T("(Entity me,Attr):i"),CompName);
    component.addProt(_T("exit"),ATTR_ADDR1(_TEntity,exit),_T("(Entity me)"),CompName);
    component.addProt(_T("bind"),ATTR_ADDR1(_TEntity,bind),_T("(Entity me,name,Entity fun):Entity"),CompName);
    bDefaultArg.clear(); bDefaultArg.append(*CseSuper_UnknownObj);
    component.addProt(_T("unbind"),ATTR_ADDR1(_TEntity,unbind),_T("(Entity me,name,Entity fun):Entity"),CompName,bDefaultArg);
    component.addProt(_T("trigger"),ATTR_ADDR1(_TEntity,trigger),_T("(Entity me,name,*arg):Entity"),CompName);
    component.addProt(_T("each"),ATTR_ADDR1(_TEntity,each),_T("(Entity me,Entity fn,*arg):Entity"),CompName);
    SuperEntityType = component->Id_;

    // Typed array: *
    CompName = _T("*"); component = TEntityType(CompName,sizeof(_TArray::m));
    bDefaultArg.clear(); bDefaultArg.append(dummy);
    component.addProt(_T("operator()"),ATTR_ADDR1(_TArray,operator()),_T("(Entity me,SInt index,value):Entity"),CompName,bDefaultArg);
    component.addProt(_T("push"),ATTR_ADDR1(_TArray,push),_T("(Entity me,value,*args):i"),CompName);
    bDefaultArg.clear(); bDefaultArg.append(TIntObj(-1));
    component.addProt(_T("pop"),ATTR_ADDR1(_TArray,pop),_T("(Entity me,SInt index):Entity"),CompName,bDefaultArg);
    component.addProt(_T("shift"),ATTR_ADDR1(_TArray,shift),_T("(Entity me):Entity"),CompName);
    component.addProt(_T("unshift"),ATTR_ADDR1(_TArray,unshift),_T("(Entity me,value,*args):i"),CompName);
    bDefaultArg.clear(); bDefaultArg.append(TIntObj(-1));
    component.addProt(_T("sliceOf"),ATTR_ADDR1(_TArray,sliceOf),_T("(Entity me,SInt index,SInt iLen):Entity"),CompName,bDefaultArg);
    bDefaultArg.clear(); bDefaultArg.append(TCharArray(_T(",")));
    component.addProt(_T("desc"),ATTR_ADDR1(_TArray,desc),_T("(Entity me,SStr separator):s"),CompName,bDefaultArg);
    component.addProt(_T("concat"),ATTR_ADDR1(_TArray,concat),_T("(Entity me,Entity that):Entity"),CompName);
    component.addProt(_T("reverse"),ATTR_ADDR1(_TArray,reverse),_T("(Entity me):Entity"),CompName);
    bDefaultArg.clear(); bDefaultArg.append(TIntObj(-1));
    component.addProt(_T("splice"),ATTR_ADDR1(_TArray,splice),_T("(Entity me,SInt iStart,SInt iDelNum,*args):Entity"),CompName,bDefaultArg);
    SuperArrayType = component->Id_;

    // _TLinker
    CompName = _T("SLinker"); component = TEntityType(CompName,0);
    bDefaultArg.clear(); bDefaultArg.append(TIntObj(0));
    component.addProt(_T("operator()"),ATTR_ADDR1(_TLinker,operator()),_T("(me,SInt isRoot):Entity"),CompName,bDefaultArg);

    // _TSelector
    CompName = _T("S"); component = TEntityType(CompName,sizeof(_TSelector::m));
    bDefaultArg.clear(); bDefaultArg.append(dummy); bDefaultArg.append(TIntObj(0)); bDefaultArg.append(TIntObj(-1)); bDefaultArg.append(TIntObj(-1));
    component.addProt(_T("init"),ATTR_ADDR1(_TSelector,init),_T("(Entity me,SQL,SInt from,SInt num,SInt to)"),CompName,bDefaultArg);
    component.addProt(_T("operator()"),ATTR_ADDR1(_TSelector,operator()),_T("(Entity me,SInt index):Entity"),CompName);
    component.addProt(_T("join"),ATTR_ADDR1(_TSelector,join),_T("(Entity me,Entity other):Entity"),CompName);
    component.addProt(_T("exit"),ATTR_ADDR1(_TSelector,exit),_T("(Entity me):Entity"),CompName);
    bDefaultArg.clear(); bDefaultArg.append(TIntObj(0)); bDefaultArg.append(TIntObj(-1)); bDefaultArg.append(TIntObj(-1));
    component.addProt(_T("reset"),ATTR_ADDR1(_TSelector,reset),_T("(Entity me,SQL,SInt from,SInt num,SInt to):Entity"),CompName,bDefaultArg);
    component.addProt(_T("filter"),ATTR_ADDR1(_TSelector,filter),_T("(Entity me,Entity Func,*args):Entity"),CompName);
    component.addProt(_T("each"),ATTR_ADDR1(_TSelector,each),_T("(Entity me,Entity fun,*args):Entity"),CompName);
    component.addProt(_T("bind"),ATTR_ADDR1(_TSelector,bind),_T("(Entity me,name,Entity fun):Entity"),CompName);
    bDefaultArg.clear(); bDefaultArg.append(*CseSuper_UnknownObj);
    component.addProt(_T("unbind"),ATTR_ADDR1(_TSelector,unbind),_T("(Entity me,name,Entity fun):Entity"),CompName,bDefaultArg);
    component.addProt(_T("trigger"),ATTR_ADDR1(_TSelector,trigger),_T("(Entity me,name,*arg):Entity"),CompName);

    component.addProt(_T("E"),ATTR_ADDR1(__S,E),_T("(SInt eid):Entity"));
    bDefaultArg.clear(); bDefaultArg.append(TIntObj(0));
    component.addProt(_T("e"),ATTR_ADDR1(__S,e),_T("(SStr selector,SInt iNoCache):Entity"),CseEmptyStr,bDefaultArg);
    bDefaultArg.clear(); bDefaultArg.append(CseEmptyStr);
    component.addProt(_T("t"),ATTR_ADDR1(__S,t),_T("(SStr sName):Entity"),CseEmptyStr,bDefaultArg);
    _TEntity (*S_f)(const TMngInt&,TInt,TXchar,const TCseObj&) = &__S::f;
    component.addProt(_T("f"),(TInt)S_f,_T("(SInt iAddr,SStr sArgs,*default):Entity"));
    bDefaultArg.clear(); bDefaultArg.append(TIntObj(10));
    component.addProt(_T("parseInt"),ATTR_ADDR1(__S,parseInt),_T("(value,SInt radix):v"),CseEmptyStr,bDefaultArg);
    component.addProt(_T("parseFloat"),ATTR_ADDR1(__S,parseFloat),_T("(value):v"));
    component.addProt(_T("isNaN"),ATTR_ADDR1(__S,isNaN),_T("(value):i"));
    component.addProt(_T("cachedNum"),ATTR_ADDR1(__S,cachedNum),_T("():i"));
    component.addProt(_T("rootEntity"),ATTR_ADDR1(__S,rootEntity),_T("():Entity"));
    _TLinker (*S_linkTo)(const TCseObj&) = &__S::linkTo;
    component.addProt(_T("linkTo"),(TInt)S_linkTo,_T("(attr):SLinker"));
    SuperSelectorType = component->Id_;

    // SInt
    CompName = _T("SInt"); component = TEntityType(CompName,0);
    bDefaultArg.clear(); bDefaultArg.append(CseEmptyInt);
    component.addProt(_T("init"),ATTR_ADDR1(_TEntity,IntInit),_T("(Entity me,v)"),CompName,bDefaultArg);
    bSuperType.append(component->Id_);

    // SWint
    CompName = _T("SWint"); component = TEntityType(CompName,0);
    bDefaultArg.clear(); bDefaultArg.append(CseEmptyWint);
    component.addProt(_T("init"),ATTR_ADDR1(_TEntity,WintInit),_T("(Entity me,v)"),CompName,bDefaultArg);
    bSuperType.append(component->Id_);

    // SFloat
    CompName = _T("SFloat"); component = TEntityType(CompName,0);
    bDefaultArg.clear(); bDefaultArg.append(CseEmptyFloat);
    component.addProt(_T("init"),ATTR_ADDR1(_TEntity,FloatInit),_T("(Entity me,v)"),CompName,bDefaultArg);
    bDefaultArg.clear(); bDefaultArg.append(TIntObj(0));
    component.addProt(_T("toFixed"),ATTR_ADDR1(TMngFloat,toFixed),_T("(me,SInt num):s"),CompName,bDefaultArg);
    bDefaultArg.clear(); bDefaultArg.append(TIntObj(20));
    component.addProt(_T("toExponential"),ATTR_ADDR1(TMngFloat,toExponential),_T("(me,SInt num):s"),CompName,bDefaultArg);
    component.addProt(_T("toPrecision"),ATTR_ADDR1(TMngFloat,toPrecision),_T("(me,SInt num):s"),CompName);
    bSuperType.append(component->Id_);

    // SStr
    CompName = _T("SStr"); component = TEntityType(CompName,0);
    bDefaultArg.clear(); bDefaultArg.append(CseEmptyStr);
    component.addProt(_T("init"),ATTR_ADDR1(_TEntity,StrInit),_T("(Entity me,v)"),CompName,bDefaultArg);
    bDefaultArg.clear(); bDefaultArg.append(dummy);
    component.addProt(_T("operator()"),ATTR_ADDR1(TMngStr,operator()),_T("(me,SInt index,value):i"),CompName,bDefaultArg);
    component.addProt(_T("concat"),ATTR_ADDR1(TMngStr,concat),_T("(me,SStr s):SStr"),CompName);
    bDefaultArg.clear(); bDefaultArg.append(TIntObj(0));
    component.addProt(_T("indexOf"),ATTR_ADDR1(TMngStr,indexOf),_T("(me,SStr sSub,SInt iFrom):i"),CompName,bDefaultArg);
    bDefaultArg.clear(); bDefaultArg.append(TIntObj(-1));
    component.addProt(_T("replaceOf"),ATTR_ADDR1(TMngStr,replaceOf),_T("(me,SStr sSub,SStr sReplace,SInt count):SStr"),CompName,bDefaultArg);
    bDefaultArg.clear(); bDefaultArg.append(TIntObj(-1));
    component.addProt(_T("sliceOf"),ATTR_ADDR1(TMngStr,sliceOf),_T("(me,SInt index,SInt iLen):SStr"),CompName,bDefaultArg);
    bDefaultArg.clear(); bDefaultArg.append(TIntObj(-1));
    component.addProt(_T("splitOf"),ATTR_ADDR1(TMngStr,splitOf),_T("(me,SStr sSub,SInt iLimit):b"),CompName,bDefaultArg);
    component.addProt(_T("toLowerCase"),ATTR_ADDR1(TMngStr,toLowerCase),_T("(me):SStr"),CompName);
    component.addProt(_T("toUpperCase"),ATTR_ADDR1(TMngStr,toUpperCase),_T("(me):SStr"),CompName);
    component.addProt(_T("toTrim"),ATTR_ADDR1(TMngStr,toTrim),_T("(me):SStr"),CompName);
    bSuperType.append(component->Id_);

    // STier
    CompName = _T("STier"); component = TEntityType(CompName,0);
    bDefaultArg.clear(); bDefaultArg.append(CseEmptyTier);
    component.addProt(_T("init"),ATTR_ADDR1(_TEntity,TierInit),_T("(Entity me,v)"),CompName,bDefaultArg);
    bDefaultArg.clear(); bDefaultArg.append(dummy);
    component.addProt(_T("operator()"),ATTR_ADDR1(TMngTier,operator()),_T("(me,SInt index,value):i"),CompName,bDefaultArg);
    component.addProt(_T("push"),ATTR_ADDR1(TMngTier,push),_T("(me,SInt value,*args):i"),CompName);
    bDefaultArg.clear(); bDefaultArg.append(TIntObj(-1));
    component.addProt(_T("pop"),ATTR_ADDR1(TMngTier,pop),_T("(me,SInt index):i"),CompName,bDefaultArg);
    component.addProt(_T("shift"),ATTR_ADDR1(TMngTier,shift),_T("(me):i"),CompName);
    component.addProt(_T("unshift"),ATTR_ADDR1(TMngTier,unshift),_T("(me,SInt value,*args):i"),CompName);
    component.addProt(_T("concat"),ATTR_ADDR1(TMngTier,concat),_T("(me,STier that):STier"),CompName);
    bDefaultArg.clear(); bDefaultArg.append(TIntObj(-1));
    component.addProt(_T("sliceOf"),ATTR_ADDR1(TMngTier,sliceOf),_T("(me,SInt index,SInt iLen):STier"),CompName,bDefaultArg);
    bDefaultArg.clear(); bDefaultArg.append(TCharArray(","));
    component.addProt(_T("desc"),ATTR_ADDR1(TMngTier,desc),_T("(me,SStr separator):s"),CompName,bDefaultArg);
    component.addProt(_T("reverse"),ATTR_ADDR1(TMngTier,reverse),_T("(me):STier"),CompName);
    bDefaultArg.clear(); bDefaultArg.append(TIntObj(-1));
    component.addProt(_T("splice"),ATTR_ADDR1(TMngTier,splice),_T("(me,SInt iStart,SInt iDelNum,*args):STier"),CompName,bDefaultArg);
    bSuperType.append(component->Id_);

    // SBuff
    CompName = _T("SBuff"); component = TEntityType(CompName,0);
    bDefaultArg.clear(); bDefaultArg.append(CseEmptyBuff);
    component.addProt(_T("init"),ATTR_ADDR1(_TEntity,BuffInit),_T("(Entity me,v)"),CompName,bDefaultArg);
    bDefaultArg.clear(); bDefaultArg.append(dummy);
    component.addProt(_T("operator()"),ATTR_ADDR1(TMngBuff,operator()),_T("(me,SInt index,value):v"),CompName,bDefaultArg);
    component.addProt(_T("push"),ATTR_ADDR1(TMngBuff,push),_T("(me,value,*args):i"),CompName);
    bDefaultArg.clear(); bDefaultArg.append(TIntObj(-1));
    component.addProt(_T("pop"),ATTR_ADDR1(TMngBuff,pop),_T("(me,SInt index):v"),CompName,bDefaultArg);
    component.addProt(_T("shift"),ATTR_ADDR1(TMngBuff,shift),_T("(me):v"),CompName);
    component.addProt(_T("unshift"),ATTR_ADDR1(TMngBuff,unshift),_T("(me,value,*args):i"),CompName);
    component.addProt(_T("concat"),ATTR_ADDR1(TMngBuff,concat),_T("(me,SBuff that):SBuff"),CompName);
    bDefaultArg.clear(); bDefaultArg.append(TIntObj(-1));
    component.addProt(_T("sliceOf"),ATTR_ADDR1(TMngBuff,sliceOf),_T("(me,SInt index,SInt iLen):SBuff"),CompName,bDefaultArg);
    bDefaultArg.clear(); bDefaultArg.append(TCharArray(","));
    component.addProt(_T("desc"),ATTR_ADDR1(TMngBuff,desc),_T("(me,SStr separator):s"),CompName,bDefaultArg);
    component.addProt(_T("reverse"),ATTR_ADDR1(TMngBuff,reverse),_T("(me):SBuff"),CompName);
    bDefaultArg.clear(); bDefaultArg.append(TIntObj(-1));
    component.addProt(_T("splice"),ATTR_ADDR1(TMngBuff,splice),_T("(me,SInt iStart,SInt iDelNum,*args):SBuff"),CompName,bDefaultArg);
    bSuperType.append(component->Id_);

    // SDict
    CompName = _T("SDict"); component = TEntityType(CompName,0);
    bDefaultArg.clear(); bDefaultArg.append(CseEmptyDict);
    component.addProt(_T("init"),ATTR_ADDR1(_TEntity,DictInit),_T("(Entity me,v)"),CompName,bDefaultArg);
    bDefaultArg.clear(); bDefaultArg.append(dummy);
    component.addProt(_T("operator()"),ATTR_ADDR1(TMngDict,operator()),_T("(me,key,value):v"),CompName,bDefaultArg);
    bDefaultArg.clear(); bDefaultArg.append(TCharArray(","));
    component.addProt(_T("desc"),ATTR_ADDR1(TMngDict,desc),_T("(me,SStr separator):s"),CompName,bDefaultArg);
    bSuperType.append(component->Id_);

    // SObject
    CompName = _T("SObject"); component = TEntityType(CompName,0);
    bDefaultArg.clear(); bDefaultArg.append(CseEmptyInt);
    component.addProt(_T("init"),ATTR_ADDR1(_TEntity,ObjInit),_T("(Entity me,v)"),CompName,bDefaultArg);
    bSuperType.append(component->Id_);
}
